I'm having an issue where my Android device (An HTC Incredible running stock 2.3.4 rom) is not able to receive a broadcast UDP, but when I get the IP of the device (on the same network) and send the packet directly to the IP, the phone immediately recognizes it and interprets it. I have tested with WireShark on two unrelated PCs, one not even on the same switch on this network, and both are able to see the packet (though they do call the packet "malformed") Yet the phone never receives (it doesn't require any data from the packet) so I'm wondering what's happening.
The same thing is happening in the emulator as well.
This is the current code.
m_UDPSocket = new DatagramSocket( 9000 );
m_UDPSocket.setBroadcast( true ); // unneeded?
boolean finished = false;
byte[] buf = new byte[1024];
DatagramPacket packet = new DatagramPacket(buf, buf.length);
m_UDPSocket.setSoTimeout( 1000 );
do {
finished = true;
try
{
m_UDPSocket.receive(packet);
}
catch ( SocketTimeoutException e )
{
finished = false;
System.out.print( "Socket recieve timed out" );
}
} while( finished == false );
System.out.print( buf );
InetAddress address = packet.getAddress();
So is my phone rejecting the UDP broadcast packets for some reason, any way to test that it is receiving the packet on my phone? Is this the HTC Incredible issue HTC issue , and I need to program around this?
Thank you in advance for any help you can give me on this matter.