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

(dc) DatagramChannel.connect undocumented behavior

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P4
    • 22
    • None
    • core-libs
    • b26

    Description

      It is possible to determine the local address (and NetworkInterface) for a specific destination for DatagramChannels by connecting an unbound DatagramChannel to the destination and then checking the local address. It will be the local address of the NetworkInterface you want. This also works if the channel is explicitly bound to the wildcard address (but not any local address other than the one you are looking for). This works without generating any network traffic.

      If you disconnect the channel then the local bound address becomes the wildcard again. The same behavior is seen across Windows, Linux and Macos.

      This seems like very useful behavior that should be documented.

      The same behavior exists in java.net.DatagramSocket and should be documented there also.

      Attachments

        Issue Links

          Activity

            People

              michaelm Michael McMahon
              michaelm Michael McMahon
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: