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

Update DatagramSocket to add support for joining multicast groups



    • Enhancement
    • Resolution: Fixed
    • P3
    • 17
    • 15
    • core-libs
    • b09


      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.


        Issue Links



              dfuchs Daniel Fuchs
              chegar Chris Hegarty
              0 Vote for this issue
              6 Start watching this issue