Minds when writing TCP stream

One point you should keep in mind is that when you write to a TCP

stream, you receive no acknowledgment that the other side has received the data.

Even worse, because the underlying network implementation may chop and

route your packets haphazardly, the other endpoint may have received only part

of the message you sent (even though TCP internally tries to resend the packets

that have been lost or corrupted). Remember that TCP guarantees only that the

packets are received in order by the application, not that they are received at all.

Furthermore, TCP is not message-oriented; it just provides a continuous

stream of data. If you need to distinguish individual messages, you need to

implement a framing protocol that specifi es where each message starts and

ends.

HTTP, for instance, solves these problems whereby an application needs

a request-response workfl ow from a server and request and response messages

are clearly delimited.


你可能感兴趣的:(Minds when writing TCP stream)