What are the possible causes of iPhone rejecting a UDP packet?

On the iPhone, I run an application with the AsyncUdpSocket library to take care of the UDP network. I checked it out. I can send a UDP packet from my iPhone to a server running a Java program that accepts UDP correctly.

However, when the opposite is true, the UDP message from the Java program does not reach the iPhone. So I decided to check the library to see if it can send / receive its own UDP packets or not use 127.0.0.1 on the iPhone, and as a result it works.

So I was wondering if UDP packets were being sent or not, so I used Wireshark to see my network activity.

alt text

Direct link to image above: http://img46.imageshack.us/img46/7939/screenshot20100220at110.png

In the iPhone program, I tell my UDP program to connect to 192.168.99.11, which is my MacBook, through port 55555. The Java UDP program on my Macbook says that the remote ip for the connection is 192.168.99.13 (my iPhone) on port 55555.

On Wireshark, I see ICMP telling me that the destination and port are not accessible from the iPhone.

So does anyone know why iPhone blocks UDP packets? Or am I missing something?

+4
source share
1 answer

If I don’t understand something in understanding your question, you have two client-style applications. Both are trying to connect to port 55555 on another host. I have no idea how this works for you on one box.

Let me describe a normal client-server script (aka active / passive):

  • the server creates a UDP socket and bind(2) it to a known port (55555 in your example),
  • the server calls the recv(2) -family function on the socket to receive data from clients,
  • the client creates a UDP socket and calls sendto(2) with the destination address argument initialized by the server IP address and the specified port number.
  • the server returns from recv(2) data from the client,
  • Additionally, the client and server exchange messages.

The key is that you need a connected known port on the server side. On the other hand, the server does not need to know the address and port of the client, so the server is passive and the client is active. Probably I should add that UDP applications often act on both clients and servers at the same time. It is just logical - these are separate roles.

Because of this, there may be several reasons why you will receive the message "ICMP port unreachable":

  • The process is not associated with a port on the server (see point 1 above),
  • The firewall on the server machine actively rejects packets sent to this port.

Hope this makes it a little easier. Let me know if I misunderstood what you are asking.

+2
source

Source: https://habr.com/ru/post/1301916/


All Articles