Click here to Skip to main content
Rate this: bad
good
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.
 
Thanks!
Posted 20-Nov-10 3:12am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Streaming with WCF might be for you:
 
[http://msdn.microsoft.com/en-us/library/ms731913.aspx]
  Permalink  
Rate this: bad
good
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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 480
1 Maciej Los 290
2 Richard MacCutchan 225
3 BillWoodruff 185
4 Suraj Sahoo | Coding Passion 155
0 OriginalGriff 8,764
1 Sergey Alexandrovich Kryukov 7,437
2 DamithSL 5,639
3 Maciej Los 5,279
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web01 | 2.8.1411028.1 | Last Updated 21 Nov 2010
Copyright © CodeProject, 1999-2014
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