[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

UDP socket creation





private void openSocket() {
    try {
      ds = new DatagramSocket();
      ds.bind(new InetSocketAddress(6090));
    } catch (Exception e) { System.err.println(e.getMessage());}
  }

For some reson ds.getPort() returns -1.  I do not want to use 6090.  I
want to do a ds.receive() on a UDP socket that the OS has available.  If
I specify the prot 6090 and it is not available, I will get an
Exception.  But I need ds.getPort() so I can tell the remote what port
the OS has given me to listen on.  Is there a simple easy way I'm not
seeing to do this?

Thanks,
Chris