iPhone 拒绝 UDP 数据包的可能原因有哪些?
在 iPhone 上,我正在运行一个带有 AsyncUdpSocket 库的应用程序来处理 UDP 网络。我已经测试过了。 我可以将 UDP 数据包从 iPhone 发送到运行正确接受 UDP 的 Java 程序的服务器。
但是,当情况相反时,Java 程序的 UDP 消息无法到达 iPhone .所以我决定测试这个库是否可以在iPhone上使用127.0.0.1发送/接收自己的UDP数据包,结果是它可以工作。
所以我想知道 UDP 数据包是否正在发送,所以我使用 Wireshark 来查看我的网络活动。
直接链接到上图: http://img46.imageshack.us/img46/7939/screenshot20100220at110 .png
在iPhone程序中,我指示我的UDP程序连接到192.168.99.11,这是我的MacBook,使用端口55555。我的Macbook上的Java UDP程序被告知要连接的远程IP是192.168.99.13(我的 iPhone),端口 55555。
在 Wireshark 上,我可以看到 ICMP 告诉我,iPhone 无法访问目的地和端口。
那么有人知道为什么 iPhone 会阻止 UDP 数据包吗?还是有什么我忽略的事情?
On iPhone, I am running an app with AsyncUdpSocket library to take care of UDP networking. I have tested it. I can send UDP packet from my iPhone to a server that runs Java program accepting UDP correctly.
However, when it is the other way around, Java program's UDP message doesn't get through to iPhone. So I decided to test the library whether it can send/receive its own UDP packets or not using 127.0.0.1 on iPhone, and the result is it works.
So I was wondering whether the UDP packets are being sent or not, so I used Wireshark to see my network activity.
Directlink to image above: http://img46.imageshack.us/img46/7939/screenshot20100220at110.png
In the iPhone program, I instruct my UDP program to connect to 192.168.99.11, which is my MacBook, using port 55555. The Java UDP program on my Macbook is being told that the remote ip to connect to is 192.168.99.13 (my iPhone) on port 55555.
On Wireshark, I can see that ICMP is telling me that the destination and port are unreachable from iPhone.
So does anybody know why iPhone blocks UDP packets? Or is there something I overlook?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除非我在理解您的问题时遗漏了一些内容,否则您有两个客户端样式的应用程序。两者都尝试连接到另一台主机上的端口 55555。我不知道它在单个盒子上如何为你工作。
让我描述一下正常的客户端-服务器(也称为主动/被动)场景:
recv(2)
系列函数来接受来自客户端的数据,sendto(2)
函数,其中目标地址参数使用服务器的 IP 地址和已知端口号进行初始化。recv(2)
返回来自客户端的数据,关键是你需要在服务器端绑定已知端口。另一方面,服务器不需要知道客户端的地址和端口,因此服务器是被动的,而客户端是主动的。我可能应该补充一点,UDP 应用程序同时充当客户端和服务器的情况并不罕见。从逻辑上讲,这些是不同的角色。
顺便说一句,可能有几个原因导致您收到“ICMP 端口无法访问”响应:
希望这能澄清一点。如果我严重误解了您的要求,请告诉我。
Unless I'm missing something in understanding your question you have two client-style applications. Both try to connect to port 55555 on the other host. I have no idea how it works for you on single box.
Let me describe normal client-server (a.k.a active/passive) scenario:
bind(2)
s it to known port (55555 in your example),recv(2)
-family function on the socket to accept data from clients,sendto(2)
function with destination address argument initialized with servers's IP address and that known port number.recv(2)
with the data from client,The key is that you need bound known port on the server side. Server, on the other hand, doesn't need to know address and port of the client, thus server is passive and client(s) is/are active. I should probably add that it's not uncommon for UDP applications to act as both clients and servers at the same time. It's just logically these are separate roles.
That out of the way, there could be a couple of reasons why you get "ICMP port unreachable" response:
Hope this clears it a bit. Let me know if I grossly misunderstood what you are asking.