7
votes

I am working on an Android application which sends a udp broadcast message to the devices on LAN. Application works well on the device and also on the emulator running on Windows. However, I couldn't get it working on Linux and Mac Android Emulators.

Since 255.255.255.255 is not working on android, I calculate the broadcast ip by using the subnet mask. (broadcast ip in my case is 192.168.1.255 where host ip is 192.168.1.88/24). But the message is never sent. Also checked with Wireshark but seems like the udp package does not get outside of the emulator.

Is there anyone who achieved to send broadcast messages on Linux Android Emulator?

Any advice will be highly appreciated.

1
Might be something related to permissions in Linux/Unix. With which privilages you run the emulator?Caner
Eclipse runs that up. It has read/write/execute for all users. It is not run as a super user though.İlker Temuzkuşu

1 Answers

0
votes

Could you give a sample of your code? It is important when using UDP instead of TCP to use a DatagramSocket with DatagramPackets in stead of a standard Socket or an SSLSocket (or any other kind of Socket for that matter). It seems like that might be what you're doing because it sometimes works, but it might be work trying. If that is the problem and you want any advice, this should suffice:

http://developer.android.com/reference/java/net/DatagramSocket.html