Cherry
Cherry

Reputation: 33534

Can first tcp byte be lost?

I try to understand how to send several messages over tcp. One of the practices is send message length in first byte to split while byte array into messages. Form theoreticall point of view I can get into troubles if my first byte (or first bytes) is lost, so it become impossible to split all received bytes into messages. Can first byte be lost in pratice?

Upvotes: 0

Views: 78

Answers (1)

mniip
mniip

Reputation: 796

TCP ensures that the stream is transferred unaltered, with no parts skipped, inserted, swapped, mutated, etc. If for some reason, the transport layer cannot transfer the necessary data (for example due to packet loss), the TCP driver in the operating system will try to retransmit the data, and after a few unsuccessful attempts the connection will be shut down.

Upvotes: 1

Related Questions