Class DefaultSocketFactory

  • All Implemented Interfaces:
    SocketFactory

    public class DefaultSocketFactory
    extends java.lang.Object
    implements SocketFactory
    Default implementation, ignores service names
    Author:
    Bela Ban
    • Constructor Detail

      • DefaultSocketFactory

        public DefaultSocketFactory()
      • DefaultSocketFactory

        public DefaultSocketFactory​(javax.net.ssl.SSLContext sslContext)
      • DefaultSocketFactory

        public DefaultSocketFactory​(javax.net.SocketFactory socketFactory,
                                    javax.net.ServerSocketFactory serverSocketFactory)
    • Method Detail

      • setSocketConfigurator

        public void setSocketConfigurator​(java.util.function.Consumer<java.net.Socket> socketConfigurator)
      • setServerSocketConfigurator

        public void setServerSocketConfigurator​(java.util.function.Consumer<java.net.ServerSocket> serverSocketConfigurator)
      • createSocket

        public java.net.Socket createSocket​(java.lang.String s)
                                     throws java.io.IOException
        Specified by:
        createSocket in interface SocketFactory
        Throws:
        java.io.IOException
      • createSocket

        public java.net.Socket createSocket​(java.lang.String s,
                                            java.lang.String host,
                                            int port)
                                     throws java.io.IOException
        Specified by:
        createSocket in interface SocketFactory
        Throws:
        java.io.IOException
      • createSocket

        public java.net.Socket createSocket​(java.lang.String s,
                                            java.net.InetAddress host,
                                            int port)
                                     throws java.io.IOException
        Specified by:
        createSocket in interface SocketFactory
        Throws:
        java.io.IOException
      • createSocket

        public java.net.Socket createSocket​(java.lang.String s,
                                            java.lang.String host,
                                            int port,
                                            java.net.InetAddress localHost,
                                            int localPort)
                                     throws java.io.IOException
        Specified by:
        createSocket in interface SocketFactory
        Throws:
        java.io.IOException
      • createSocket

        public java.net.Socket createSocket​(java.lang.String s,
                                            java.net.InetAddress host,
                                            int port,
                                            java.net.InetAddress localHost,
                                            int localPort)
                                     throws java.io.IOException
        Specified by:
        createSocket in interface SocketFactory
        Throws:
        java.io.IOException
      • createServerSocket

        public java.net.ServerSocket createServerSocket​(java.lang.String s)
                                                 throws java.io.IOException
        Specified by:
        createServerSocket in interface SocketFactory
        Throws:
        java.io.IOException
      • createServerSocket

        public java.net.ServerSocket createServerSocket​(java.lang.String s,
                                                        int port)
                                                 throws java.io.IOException
        Specified by:
        createServerSocket in interface SocketFactory
        Throws:
        java.io.IOException
      • createServerSocket

        public java.net.ServerSocket createServerSocket​(java.lang.String s,
                                                        int port,
                                                        int backlog)
                                                 throws java.io.IOException
        Specified by:
        createServerSocket in interface SocketFactory
        Throws:
        java.io.IOException
      • createServerSocket

        public java.net.ServerSocket createServerSocket​(java.lang.String s,
                                                        int port,
                                                        int backlog,
                                                        java.net.InetAddress bindAddress)
                                                 throws java.io.IOException
        Specified by:
        createServerSocket in interface SocketFactory
        Throws:
        java.io.IOException
      • createDatagramSocket

        public java.net.DatagramSocket createDatagramSocket​(java.lang.String service_name)
                                                     throws java.net.SocketException
        Specified by:
        createDatagramSocket in interface SocketFactory
        Throws:
        java.net.SocketException
      • createDatagramSocket

        public java.net.DatagramSocket createDatagramSocket​(java.lang.String service_name,
                                                            java.net.SocketAddress bindaddr)
                                                     throws java.net.SocketException
        Specified by:
        createDatagramSocket in interface SocketFactory
        Throws:
        java.net.SocketException
      • createDatagramSocket

        public java.net.DatagramSocket createDatagramSocket​(java.lang.String service_name,
                                                            int port)
                                                     throws java.net.SocketException
        Specified by:
        createDatagramSocket in interface SocketFactory
        Throws:
        java.net.SocketException
      • createDatagramSocket

        public java.net.DatagramSocket createDatagramSocket​(java.lang.String service_name,
                                                            int port,
                                                            java.net.InetAddress laddr)
                                                     throws java.net.SocketException
        Specified by:
        createDatagramSocket in interface SocketFactory
        Throws:
        java.net.SocketException
      • createMulticastSocket

        public java.net.MulticastSocket createMulticastSocket​(java.lang.String service_name)
                                                       throws java.io.IOException
        Specified by:
        createMulticastSocket in interface SocketFactory
        Throws:
        java.io.IOException
      • createMulticastSocket

        public java.net.MulticastSocket createMulticastSocket​(java.lang.String service_name,
                                                              int port)
                                                       throws java.io.IOException
        Specified by:
        createMulticastSocket in interface SocketFactory
        Throws:
        java.io.IOException
      • createMulticastSocket

        public java.net.MulticastSocket createMulticastSocket​(java.lang.String service_name,
                                                              java.net.SocketAddress bindaddr)
                                                       throws java.io.IOException
        Specified by:
        createMulticastSocket in interface SocketFactory
        Throws:
        java.io.IOException
      • close

        public void close​(java.net.Socket socket)
                   throws java.io.IOException
        Specified by:
        close in interface SocketFactory
        Throws:
        java.io.IOException
      • close

        public void close​(java.net.ServerSocket serverSocket)
                   throws java.io.IOException
        Specified by:
        close in interface SocketFactory
        Throws:
        java.io.IOException
      • close

        public void close​(java.net.DatagramSocket datagramSocket)
        Specified by:
        close in interface SocketFactory
      • getSockets

        public java.util.Map<java.lang.Object,​java.lang.String> getSockets()
        Description copied from interface: SocketFactory
        Returns all open sockets. This method can be used to list or close all open sockets.
        Specified by:
        getSockets in interface SocketFactory
        Returns:
        A map of open sockets; keys are Sockets, ServerSockets, DatagramSockets or MulticastSockets, values are the service names.