Receiving UDP on different Android phones gives different results

Posted by user1868982 on Stack Overflow See other posts from Stack Overflow or by user1868982
Published on 2012-12-01T17:02:40Z Indexed on 2012/12/01 17:03 UTC
Read the original article Hit count: 133

Filed under:
|
|
|

I am willing to create a server and client program on my android mobile devices. The devices communicate with each other on the same wifi network, therefore, some simple scanning mechanism must be implemented - The client phones search for a server phone through some kind of broadcast.

What I did:

My protocol - the client phone broadcasts a message port p on the wifi, the server listens on port p. when the server gets the broadcast message it sends a message back, therefore discovering itself to the client.

My code - I have opened a broadcast socket on my app, it sends a broadcast message. Meanwhile there is a python script on my PC that listens and replies - I use python so that my testing will be easier - Wireshark on the PC and I can see everything.

What happens:

When I use one of my Galaxy S phones - it works and I get a response. When I use the other Galaxy S phone - it doesn't work.

Now this is what I know: The phone that works actually has Nexus ROM on it Ver. 4.1.1 The phone that doesn't work has 2.3.3 regular galaxy ROM

The python code says it receives both of the broadcasts sent from both phones, and replies to both of them without raising any exception.

So far I was thought the problem may be 1. the older version'd phone. 2. the windows firewall 3. the router firewall

So I have opened Wireshark, and Indeed I saw that both phones are sending their broadcasts - it was logged on Wireshark. But the python script only responded to the first one. So this is why 1 & 3 are irrelevant - if the router firewall was blocking my UDP I would have still seen the python server response, same with the older versioned phone.

To get rid of 2 i just disabled the windows firewall - still same problem.

Does anyone has a clue to why this effect might happen?

Thanks!

© Stack Overflow or respective owner

Related posts about android

Related posts about udp