Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4500266

DatagramSocket.isBound reports 'false' when socket implicitly bound

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.4.0
    • core-libs
    • None
    • beta3
    • generic
    • generic


      DatagramSocket.isBound() reports false if the socket is bound
      implicitly :-

      import java.net.*;

      public class Test {
          public static void main(String args[]) throws Exception {
      DatagramSocket s = new DatagramSocket((SocketAddress)null);
      s.setBroadcast(true);
      byte b[] = "hello".getBytes();
      InetAddress ia = InetAddress.getByName("localhost");
      DatagramPacket pac = new DatagramPacket(b, b.length, ia, 2000);
      s.send(pac);
      if (!isBound()) {
         InetSocketAddress isa = new InetSocketAddress(isa, 3000);
      s.bind(isa);
      }
         }
      }

            jccollet Jean-Christophe Collet (Inactive)
            alanb Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: