Click here to Skip to main content
12,998,423 members (89,070 online)
Rate this:
Please Sign up or sign in to vote.
Hi Everyone,

I'm working on a program that needs to transmit some information to a remote server for processing. I have packaged the two objects into a byte stream, but seem to be having trouble figuring out how to send both of them.

There are a lot of great examples out there for sending data using sockets and TcpClients, howerver I haven't seen any that demonstrate sending different types of data, and decyphering them on the other end.

For example, I have Object A, and Object B that I need to send. I can successfully send Object A, or Object B, but not both. I've tried sending them one after the other but seem to run into issues with the socket closing on me after the first one, and I've also tried sending both as a big byte array, but got stuck on the other end trying to figure out how to find the seperation between object A and Object B.

Does anyone have any good best practices for 'continued communications?' (I'm guessing at the name...I'm not entirely sure what this would be considered. Is it better to use a networkstream with a socket, or tcpclient? Any help or examples would be greatly appreciated.

Posted 20-Nov-10 2:12am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Streaming with WCF might be for you:

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Hi Jim,

Thank you for helping me with this. After reading through that, It also makes more sense now to use buffering instead of streaming as I need all the information there before I can deserialize, and it also helped me stumble across another example article found here.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170622.1 | Last Updated 21 Nov 2010
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100