TCP消息的顺序? [英] The order of TCP message?

查看:39
本文介绍了TCP消息的顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发使用 TCP 的 C++ 应用程序服务器和客户端.我在服务器上有三个消息:A、B 和 C.它们按顺序发送:A -> B -> C.客户端响应确认消息:rA、rB、rC.

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.

客户是否按照 A->B-C 的顺序接收 A、B 和 C?服务器是否收到 rA->rB->rC?

Do client receive A, B and C in order A->B-C? Do server receive rA->rB->rC?

推荐答案

TCP 保证接收数据包的顺序(在单个连接上)与发送它们的顺序相同.但是,如果您有多个 TCP 连接,则没有这样的保证 - TCP 仅保留给定 TCP 连接内的数据包的排序.

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.

请参阅维基百科关于 TCP 的文章,了解更多概述.

See the Wikipedia article on TCP for more overview.

TCP 的功能之一是通过将数据包重新组合成顺序或强制重试无序数据包来防止数据的无序传送.

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.

这篇关于TCP消息的顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆