Mastering Development System & Network

How to make sure a mobile phone can reach a PC on the same network?

I am developing a game that uses a PC as a monitor and a mobile phone as a gesture detector. Both devices communicate using UDP on the same local network (mostly Wi-Fi).

First, the PC creates a socket and displays its IP address and port for the mobile phone to connect by sending messages to.
However, sometimes, the phone would not be able to find the PC. The messages were sent, but the PC would not receive them (Checked with Wireshark. No incoming message on the PC). Even the address and port were correct. But, if the PC manages to ping the phone successfully, the messages sent after that point will arrive just fine.

The problem is, sometimes, especially after switching to another local network, the ping is unsuccessful. We discovered that both devices could not ping each other. The error message from the PC is :
Reply From <Host IP Address>: Destination Host Unreachable
Notice that the IP address is of the pinging host. Moreover, there was not an entry of the mobile phone inside the ARP table of the PC. So, we went further and cleared the ARP table of the PC, but it was still not able to ping each other.

We managed to make the problem disappear by using another phone to ping the PC and the first phone. Then, the ping for both problematic devices will succeed. I am not sure if that is really the solution as I do not know the cause of it. I am also not sure if it is caused by the router configuration or firewall because sometimes it works just fine without doing anything.

The game was released to the users now and some of them reported the connection problem. we can still avoid it by telling them to use another network. However, I want to know the true cause of it so that we can get rid of it permanently.

Leave a Reply

Your email address will not be published. Required fields are marked *