Click here to Skip to main content
15,886,919 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# windows application system and cloud Pin
Dave Kreskowiak10-May-17 2:35
mveDave Kreskowiak10-May-17 2:35 
AnswerRe: C# windows application system and cloud Pin
Afzaal Ahmad Zeeshan10-May-17 5:31
professionalAfzaal Ahmad Zeeshan10-May-17 5:31 
QuestionC# Network and streams Pin
TheTrigger9-May-17 11:12
TheTrigger9-May-17 11:12 
AnswerRe: C# Network and streams Pin
Bernhard Hiller9-May-17 21:30
Bernhard Hiller9-May-17 21:30 
GeneralRe: C# Network and streams Pin
TheTrigger10-May-17 2:26
TheTrigger10-May-17 2:26 
GeneralRe: C# Network and streams Pin
Dave Kreskowiak10-May-17 2:38
mveDave Kreskowiak10-May-17 2:38 
GeneralRe: C# Network and streams Pin
TheTrigger10-May-17 2:52
TheTrigger10-May-17 2:52 
GeneralRe: C# Network and streams Pin
Dave Kreskowiak10-May-17 4:31
mveDave Kreskowiak10-May-17 4:31 
You should never have a Sleep anywhere in your network code.

Also, you're receive code seems to think that when a client sends a message, you get the entire message in one go without regard to a message potentially being split up into multiple Reads. You Read however many bytes are told you received and deserialize them, even if the message is incomplete. The next read will also fail to deserialize properly because now you don't have the first part of the message but you have the trailing end of it, not a complete message.

Your losing "messages", not packets. Those are two totally separate concepts and cannot be used interchangeably.

It would seems that your client and server code has no method of delineating messages from each other. Where in the stream of bytes read can your code determine that a new message has started? You should only try to deserialize the data when you are sure you have a complete message in the buffer. That's what you have to implement.
A guide to posting questions on CodeProject

Click this: Asking questions is a skill.
Seriously, do it.

Dave Kreskowiak

GeneralRe: C# Network and streams Pin
TheTrigger10-May-17 5:48
TheTrigger10-May-17 5:48 
GeneralRe: C# Network and streams Pin
Dave Kreskowiak10-May-17 6:41
mveDave Kreskowiak10-May-17 6:41 
GeneralRe: C# Network and streams Pin
TheTrigger10-May-17 9:12
TheTrigger10-May-17 9:12 
GeneralRe: C# Network and streams Pin
Dave Kreskowiak10-May-17 11:52
mveDave Kreskowiak10-May-17 11:52 
GeneralRe: C# Network and streams Pin
TheTrigger10-May-17 22:48
TheTrigger10-May-17 22:48 
AnswerRe: C# Network and streams Pin
Gerry Schmitz10-May-17 5:00
mveGerry Schmitz10-May-17 5:00 
GeneralRe: C# Network and streams Pin
TheTrigger10-May-17 5:56
TheTrigger10-May-17 5:56 
GeneralRe: C# Network and streams Pin
Dave Kreskowiak10-May-17 6:25
mveDave Kreskowiak10-May-17 6:25 
GeneralRe: C# Network and streams Pin
TheTrigger10-May-17 8:50
TheTrigger10-May-17 8:50 
QuestionLabel link on top of the page Pin
Member 131892689-May-17 3:51
Member 131892689-May-17 3:51 
AnswerRe: Label link on top of the page Pin
Richard MacCutchan9-May-17 4:51
mveRichard MacCutchan9-May-17 4:51 
AnswerRe: Label link on top of the page Pin
OriginalGriff9-May-17 5:36
mveOriginalGriff9-May-17 5:36 
QuestionC#: How to compare variables by value and reference type Pin
Tridip Bhattacharjee8-May-17 22:24
professionalTridip Bhattacharjee8-May-17 22:24 
AnswerHelp vampire Pin
Pete O'Hanlon8-May-17 23:05
mvePete O'Hanlon8-May-17 23:05 
GeneralRe: Help vampire Pin
OriginalGriff9-May-17 0:51
mveOriginalGriff9-May-17 0:51 
GeneralRe: Help vampire Pin
Gerry Schmitz9-May-17 6:15
mveGerry Schmitz9-May-17 6:15 
AnswerRe: C#: How to compare variables by value and reference type Pin
Richard MacCutchan8-May-17 23:25
mveRichard MacCutchan8-May-17 23:25 

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.