PDA

Click to See Complete Forum and Search --> : [2.0] Sockets and out of order messages.


Pc_Madness
Nov 27th, 2006, 03:39 AM
Hey guys, I just need to clarify how out of order can a message be when using Sockets.

I've read that say the message,
"This is a sample message"

Can come in dribs and drabs,
"This is"
"a sample"
"message"

Obviously in this case, the solution is just add a marker to point out the start and end of a message, however is it possible for messages to come in this order...

"message"
"This is"
"a sample"

? As that'd make the marker a fairly trivial solution. :\

Or another situation, say for example the server does,
.Send("My Message");
.Send("Another message straight after");

Could they be jumbled up with each other as well as jumbled up amongst themselves? or will it always be one send then the other?

Buoy
Nov 28th, 2006, 10:01 AM
AFAIK, if you use TCP, you're guaranteed to get the messages in order. If you use UDP, you're not, nor or you guaranteed to get the message at all.

As far as one message being split over multiple packets, or two messages being stuck together in one packet, yeah, that happens. That's why you need an end of text marker or whatever like you mentioned.