Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.

Thanks!
Posted

Streaming with WCF might be for you:

[http://msdn.microsoft.com/en-us/library/ms731913.aspx]
 
Share this answer
 
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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900