Re: Reliability of Java, sockets and TCP transmissions
- From: Roedy Green <see_website@xxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 06 Oct 2007 10:25:26 GMT
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
.
- References:
- Reliability of Java, sockets and TCP transmissions
- From: Qu0ll
- Re: Reliability of Java, sockets and TCP transmissions
- From: Gordon Beaton
- Re: Reliability of Java, sockets and TCP transmissions
- From: Qu0ll
- Re: Reliability of Java, sockets and TCP transmissions
- From: Gordon Beaton
- Reliability of Java, sockets and TCP transmissions
- Prev by Date: Re: Reliability of Java, sockets and TCP transmissions
- Next by Date: Re: chopping of string
- Previous by thread: Re: Reliability of Java, sockets and TCP transmissions
- Next by thread: Re: Reliability of Java, sockets and TCP transmissions
- Index(es):
Relevant Pages
|
|