The order of TCP message?
I'm developing C++ application server and client which use TCP. I have three messages on server: A, B and C. They are sent sequentially: A ->开发者_StackOverflow中文版 B -> C. And clients responses acknowledge messages:rA, rB, rC.
Do client receive A, B and C in order A->B-C? Do server receive rA->rB->rC?
TCP guarantees that the order the packets are received (on a single connection) is the same as the order they were sent. No such guarantee if you've got multiple TCP connections, though - TCP preserves ordering only for the packets within a given TCP connection.
See the Wikipedia article on TCP for more overview.
One of the functions of TCP is to prevent the out-of-order delivery of data, either by reassembling packets into order or forcing retries of out-of-order packets.
精彩评论