I'm trying to write a simple game-room api and am having trouble
broadcasting to the local network's broadcast ip.  I got the code for
getting the broadcast address and how to send stuff to it here:

http://code.google.com/p/boxeeremote/wiki/AndroidUDP

and used it like this:

        int PORT = 55555;
        int DISCOVERY_PORT = 55556;

public void broadcast(String message) throws Exception {
                InetAddress ina = mContext.getBroadcastAddress(); // this is 
working
                Log.v("ADDRESS", ina.getCanonicalHostName());
                DatagramSocket socket = new DatagramSocket(PORT);  // here's 
where
the error occurs
                socket.setBroadcast(true);
                socket.setReuseAddress(true);
                DatagramPacket packet = new DatagramPacket(message.getBytes(),
message
                                .length(), ina, DISCOVERY_PORT);
                socket.send(packet);
        }

I get an error "java.net.BindException: The address is already in
use".  I thought at first this was because my local network was
blocking ports, but once I got onto my home network which blocks
nothing it still had the same issue.  Is there something extra I have
to include to get it to send a packets to the broadcast ip?  Thanks in
advance for any replies.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to