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

Update DatagramSocket to add support for joining multicast groups

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 15
    • Fix Version/s: 17
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b09

      Description

      Evaluate how to write a custom DatagramSocket/MulticastSocket without using DatagramSocketImplFactory.

      This issue has been file as a result of a discussion raised during a code view for 8236925, see https://mail.openjdk.java.net/pipermail/net-dev/2020-January/013514.html

      Though DatagramSocket has a protected constructor that allows to pass a DatagramSocketImpl instance, MulticastSocket doesn't.
      There are two ways to provide a complete custom implementation of DatagramSocket:
        - Subclass DatagramSocket and pass a custom DatagramSocketImpl instance that reimplement the whole functionality
        - Subclass DatagramSocket and pass a non functional DatagramSocketImpl instance, and override all methods in DatagramSocket so that DatagramSocketImpl is never called.
      In both cases, the default DatagramSocket implementation will not be created - and there will be no file descriptor leak.

      This is unfortunately not possible with MulticastSocket: if you subclass MulticlassSocket, the default implementation will *always* be created, even if it's never used. The only solution to avoid that is currently to replace the default DatagramSocketImplFactory by calling the static DatagramSocket.setDatagramSocketImplFactory. We need a better solution.

      The solution proposed in this RFE is to allow DatagramSocket to both send and receive multicast datagrams. An application that need to completely replace the default multicast implementation, and that cannot be easily updated to use DatagramChannel, can do so by subclassing DatagramSocket instead.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dfuchs Daniel Fuchs
              Reporter:
              chegar Chris Hegarty
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: