DatagramSocket/DatagramChannel::connect and DatagramSocket/DatagramChannel::send could explicitly use localhost when the specified peer address is the wildcard

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: P4
    • tbd
    • Affects Version/s: None
    • Component/s: core-libs
    • None

      Rather than relying on undocumented kernel specific behavior, DatagramSocket::connect and DatagramSocket::send could explicitly use localhost when the specified peer address is the wildcard (and same for DatagramChannel and its socket adaptor).

      This would allow to do things like:

      var listener = new DatagramSocket(0);
      var sender = new DatagramSocket(0);
      var packet = new DatagramPacket(buf, buf.length);
      sender.connect(listener.getLocalSocketAddress());
      sender.send(packet);

      which currently only works on mac when -Djava.net.preferIPv4Stack is specified.

            Assignee:
            Daniel Fuchs
            Reporter:
            Daniel Fuchs
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: