Why do I get UDP datagrams out of order even with processes running locally?(为什么即使进程在本地运行,我也会让 UDP 数据报乱序?)
问题描述
我正在开发流媒体服务器和 Flash 客户端之间的 Java 接口.我注意到即使两个进程都在本地运行,UDP 数据报也可以无序地到达我的接口.
I'm developing a java interface between a streaming server and a flash client. I noticed that UDP datagrams can reach my interface out of order even if both processes are running locally.
这正常吗?我认为由于没有数据报必须通过任何路由器或任何网络设备,所以不应该发生这种情况.
Is that normal? I thought that as no datagram has to go through any router or any network device, then that should not be happening.
推荐答案
实际上,UDP 数据包的排序和接收并不能保证,即使它们是由 localhost 在 localhost 上发送的.只是因为协议的规范并不暗示它.
Actually there are no guarantees of ordering and reception about UDP packets, even if they are sent by localhost on localhost. Just because the specification of the protocol doesn't imply anything about it.
由于您无法对它们做出假设,因此您应该选择使用 TCP 或使用程序处理的序列号来处理重新排序.
Since you can't make assumptions on them you should choose to use TCP or handle reordering by using a sequence number handled by your programs..
这篇关于为什么即使进程在本地运行,我也会让 UDP 数据报乱序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么即使进程在本地运行,我也会让 UDP 数据报乱序?


基础教程推荐
- 不推荐使用 Api 注释的描述 2022-01-01
- 从 python 访问 JVM 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 大摇大摆的枚举 2022-01-01
- Java Swing计时器未清除 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 多个组件的复杂布局 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01