Click here to Skip to main content
15,925,399 members
Home / Discussions / C#
   

C#

 
QuestionSockets Best Practices Pin
menzelAtPCA18-Dec-08 6:43
menzelAtPCA18-Dec-08 6:43 
Assumptions:
1) Local Intranet - non-public traffic
2) A single 'server' application will accept ISerializable objects from up to 25 different clients.
3) Objects are not sent at predetermined times (IE not on a timer) but by user interaction

I'm trying to figure out the best way to send objects over TCP. Lets say these objects range from 355 bytes all the way up to 69500 bytes.

Because we're dealing with 25 different clients I'd like this all done asyncronously.

Now, there's 2 ways I can think to do this.
1)
Asyncronously accept a Header class with an (int)size and a System.Type variables using Socket.BeginReceive(). In testing, this header class is about 300-400 bytes. On receipt of this object, create a byte array of the size indicated in the Header object. Then do a blocking .Receive() for the actual object.
On the clients, I'd first send this Header object over, followed immediatly by the actual object.

2)
Ignore the header class, just send over the entire object. On the server, use a buffer to concat say 1024 bytes at a time until the object does not fail a try/catch DeSerialize method.

I've got both ways working, #2 seems messy, because I'm relying on try/catch clauses. However, I've tried neither on a larger roll out. Is there perhaps a better way of doing this?
AnswerRe: Sockets Best Practices Pin
led mike18-Dec-08 7:53
led mike18-Dec-08 7:53 
AnswerRe: Sockets Best Practices Pin
Ben Fair18-Dec-08 8:54
Ben Fair18-Dec-08 8:54 
Questionenter instead tab key Pin
ArielR18-Dec-08 6:25
ArielR18-Dec-08 6:25 
AnswerRe: enter instead tab key Pin
Giorgi Dalakishvili18-Dec-08 7:19
mentorGiorgi Dalakishvili18-Dec-08 7:19 
QuestionHow to add video in Visual Studio C# Pin
Sokka9318-Dec-08 5:59
Sokka9318-Dec-08 5:59 
AnswerRe: How to add video in Visual Studio C# Pin
Dave Kreskowiak18-Dec-08 8:28
mveDave Kreskowiak18-Dec-08 8:28 
QuestionKeeping data at the top of the command prompt Pin
SuperSken18-Dec-08 4:32
SuperSken18-Dec-08 4:32 
AnswerRe: Keeping data at the top of the command prompt Pin
Eddy Vluggen18-Dec-08 4:35
professionalEddy Vluggen18-Dec-08 4:35 
GeneralRe: Keeping data at the top of the command prompt Pin
SuperSken18-Dec-08 4:59
SuperSken18-Dec-08 4:59 
GeneralRe: Keeping data at the top of the command prompt Pin
Eddy Vluggen18-Dec-08 6:56
professionalEddy Vluggen18-Dec-08 6:56 
GeneralRe: Keeping data at the top of the command prompt Pin
Alan N18-Dec-08 7:13
Alan N18-Dec-08 7:13 
QuestionFuntion call Pin
hotthoughtguy18-Dec-08 4:05
hotthoughtguy18-Dec-08 4:05 
AnswerRe: Funtion call Pin
Simon P Stevens18-Dec-08 4:14
Simon P Stevens18-Dec-08 4:14 
AnswerRe: Funtion call Pin
Gideon Engelberth18-Dec-08 4:22
Gideon Engelberth18-Dec-08 4:22 
GeneralRe: Funtion call Pin
Luc Pattyn18-Dec-08 5:57
sitebuilderLuc Pattyn18-Dec-08 5:57 
GeneralRe: Funtion call Pin
hotthoughtguy18-Dec-08 6:21
hotthoughtguy18-Dec-08 6:21 
GeneralRe: Funtion call Pin
Luc Pattyn18-Dec-08 6:57
sitebuilderLuc Pattyn18-Dec-08 6:57 
AnswerRe: Funtion call Pin
riced18-Dec-08 12:55
riced18-Dec-08 12:55 
QuestionHow to resume or pause the FTPWebRequest in C#.NET Pin
Kumaran21cen18-Dec-08 3:49
Kumaran21cen18-Dec-08 3:49 
AnswerRe: How to resume or pause the FTPWebRequest in C#.NET Pin
Dave Kreskowiak18-Dec-08 4:22
mveDave Kreskowiak18-Dec-08 4:22 
QuestionHow come this If sentence doesnt work? Pin
Matjaz-xyz18-Dec-08 3:20
Matjaz-xyz18-Dec-08 3:20 
AnswerRe: How come this If sentence doesnt work? Pin
Gideon Engelberth18-Dec-08 3:25
Gideon Engelberth18-Dec-08 3:25 
GeneralRe: How come this If sentence doesnt work? Pin
Matjaz-xyz18-Dec-08 3:40
Matjaz-xyz18-Dec-08 3:40 
GeneralRe: How come this If sentence doesnt work? Pin
Pr@teek B@h!18-Dec-08 5:23
Pr@teek B@h!18-Dec-08 5:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.