Re: Reliability of Java, sockets and TCP transmissions



On 06 Oct 2007 07:36:07 GMT, Gordon Beaton <n.o.t@xxxxxxxxx> wrote,
quoted or indirectly quoted someone who said :

TCP gives you a data *stream*. So if you send 512 bytes and then
another 512 bytes, the only guarantee is that the 1024 bytes will
arrive in the correct order. There is nothing in the stream to
separate the two messages from each other, that's the responsibility
of your application, for example by terminating each message with a
unique character the application can recognize, or by prefixing each
message with its length.

If for some reason a message is garbled (by software or user error),
when you start reading, you won't necessarily pick up at the beginning
of the next message. You may pick up in the middle of the garbled
message, or part way through the next good one. If you want to be
able to recover, you need to reserve some magic start of message
pattern to scan for, that won't occur incidentally in data.

Socket communications generally require you to know the precise length
of things before you put them on the wire.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
.



Relevant Pages

  • Re: Polytone Mini Brute III
    ... It's not the buyers ... While it might be confusing to say that the sale is ... He'll guarantee that the thing works, ... > He won't take it back for any other reason. ...
    (alt.guitar.bass)
  • Re: Question for Mike Plowman re CSVU Net
    ... Actually I give to charity on a very regular basis. ... reason why this one issue has been discussed at great length in here ... guarantee and the matter would have been quickly resolved and dropped. ... than the car Hopeless probably drives.] ...
    (uk.media.tv.misc)
  • Re: Find the number of lines in a text file
    ... The header is not a problem to skip but the footer is. ... Of course this relies on this guarantee! ... process just the body" - isn't it possible to do everything by reading ...
    (comp.lang.java.programmer)
  • Re: Federers message to fans on his illness
    ... people have posted about this illness, ... but there is certainly no guarantee that he is fit now. ... I guess his reason for not telling anyone until now is to avoid vulnerability speculations from his opponents, but still I think many people starts to wonder if this is a bad excuse. ... Of course his diagnosis is not fake, but also a disease is a relative term. ...
    (rec.sport.tennis)
  • Re: Federers message to fans on his illness
    ... people have posted about this illness, ... but there is certainly no guarantee that he is fit now. ... I guess his reason for not telling anyone until now is to avoid vulnerability speculations from his opponents, but still I think many people starts to wonder if this is a bad excuse. ... Of course his diagnosis is not fake, but also a disease is a relative term. ...
    (rec.sport.tennis)