user469786
user469786

Reputation: 71

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 -> 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?

Upvotes: 7

Views: 3822

Answers (1)

Michael Petrotta
Michael Petrotta

Reputation: 60962

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.

Upvotes: 11

Related Questions