为什么即使进程在本地运行,我也会让 UDP 数据报乱序?

Why do I get UDP datagrams out of order even with processes running locally?(为什么即使进程在本地运行,我也会让 UDP 数据报乱序?)

本文介绍了为什么即使进程在本地运行,我也会让 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 数据报乱序?

基础教程推荐