TCP保证按顺序到达吗? [英] Is TCP Guaranteed to arrive in order?

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

问题描述

如果发送两条TCP报文,是否需要处理后者先于前者到达的情况?还是保证按我发送的顺序到达?我认为这不是特定于 Twisted 的示例,因为它应该符合 TCP 标准,但是如果熟悉 Twisted 的任何人可以为我自己的安心提供特定于 Twisted 的答案,那将不胜感激:-)

If I send two TCP messages, do I need to handle the case where the latter arrives before the former? Or is it guaranteed to arrive in the order I send it? I assume that this is not a Twisted-specific example, because it should conform to the TCP standard, but if anyone familiar with Twisted could provide a Twisted-specific answer for my own peace of mind, that'd be appreciated :-)

推荐答案

只要两条消息在同一个 TCP 连接上发送,顺序就会保持不变.如果在同一对进程之间打开多个连接,您可能会遇到麻烦.

As long as the two messages were sent on the same TCP connection, order will be maintained. If multiple connections are opened between the same pair of processes, you may be in trouble.

关于 Twisted 或任何其他异步事件系统:我希望您会按照接收字节的顺序获得 dataReceived 消息.但是,如果您开始将工作推到延迟调用上,您可以,呃...扭曲"您的控制流,使其无法识别.

Regarding Twisted, or any other asynchronous event system: I expect you'll get the dataReceived messages in the order that bytes are received. However, if you start pushing work off onto deferred calls, you can, erm... "twist" your control flow beyond recognition.

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

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