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 数据报乱序?
基础教程推荐
- 控制台应用程序中的 Java 键盘输入解析 2022-01-01
- 将 double 转换为 Int,向下舍入 2022-01-01
- 将 Windows 证书导入 Java 2022-01-01
- JPA惰性列表上的流 2022-01-01
- Java ECDSAwithSHA256 签名长度不一致 2022-01-01
- 在springboot中如何给mybatis加拦截器 2023-04-29
- 在java中使用xpath和selenium解析HTML表格数据 2022-01-01
- doFilter()是在servlet的工作完成之前还是之后执行的? 2022-01-01
- Maven:无效的目标版本:10 2022-01-01
- 如何在相机中应用自定义滤镜 [Surfaceview 预览]. 2022-01-01
