TCP保证按顺序到达吗?

编程入门 行业动态 更新时间:2024-10-27 00:26:27
本文介绍了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保证按顺序到达吗?

本文发布于:2023-10-18 02:20:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1502794.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:顺序   TCP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!