Interface SocketFactory

  • All Known Implementing Classes:
    DefaultSocketFactory

    public interface SocketFactory
    Factory to create various types of sockets. For socket creation, a service name can be passed as argument: an implementation could look up a service description (e.g. port) and create the socket, ignoring the passed port and possibly also the bind address.

    Ephemeral ports can be created by passing 0 as port, or (if the port is ignored), an implementation could pass in a special service name (e.g. "EPHEMERAL"), this is implementation dependent.

    The socket creation methods have the same parameter lists as the socket constructors, e.g. createServerSocket(String, int, int) is the same as ServerSocket(int, int).

    Author:
    Bela Ban
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      void close​(java.net.DatagramSocket sock)  
      void close​(java.net.ServerSocket sock)  
      void close​(java.net.Socket sock)  
      default void close​(java.nio.channels.ServerSocketChannel channel)  
      default void close​(java.nio.channels.SocketChannel channel)  
      java.net.DatagramSocket createDatagramSocket​(java.lang.String service_name)  
      java.net.DatagramSocket createDatagramSocket​(java.lang.String service_name, int port)  
      java.net.DatagramSocket createDatagramSocket​(java.lang.String service_name, int port, java.net.InetAddress laddr)  
      java.net.DatagramSocket createDatagramSocket​(java.lang.String service_name, java.net.SocketAddress bindaddr)  
      java.net.MulticastSocket createMulticastSocket​(java.lang.String service_name)  
      java.net.MulticastSocket createMulticastSocket​(java.lang.String service_name, int port)  
      java.net.MulticastSocket createMulticastSocket​(java.lang.String service_name, java.net.SocketAddress bindaddr)  
      java.net.ServerSocket createServerSocket​(java.lang.String service_name)  
      java.net.ServerSocket createServerSocket​(java.lang.String service_name, int port)  
      java.net.ServerSocket createServerSocket​(java.lang.String service_name, int port, int backlog)  
      java.net.ServerSocket createServerSocket​(java.lang.String service_name, int port, int backlog, java.net.InetAddress bindAddr)  
      default java.nio.channels.ServerSocketChannel createServerSocketChannel​(java.lang.String service_name)  
      default java.nio.channels.ServerSocketChannel createServerSocketChannel​(java.lang.String service_name, int port)  
      default java.nio.channels.ServerSocketChannel createServerSocketChannel​(java.lang.String service_name, int port, int backlog)  
      default java.nio.channels.ServerSocketChannel createServerSocketChannel​(java.lang.String service_name, int port, int backlog, java.net.InetAddress bindAddr)  
      java.net.Socket createSocket​(java.lang.String service_name)  
      java.net.Socket createSocket​(java.lang.String service_name, java.lang.String host, int port)  
      java.net.Socket createSocket​(java.lang.String service_name, java.lang.String host, int port, java.net.InetAddress localAddr, int localPort)  
      java.net.Socket createSocket​(java.lang.String service_name, java.net.InetAddress address, int port)  
      java.net.Socket createSocket​(java.lang.String service_name, java.net.InetAddress address, int port, java.net.InetAddress localAddr, int localPort)  
      default java.nio.channels.SocketChannel createSocketChannel​(java.lang.String service_name)  
      default java.nio.channels.SocketChannel createSocketChannel​(java.lang.String service_name, java.net.SocketAddress bindAddr)  
    • Method Detail

      • createSocket

        java.net.Socket createSocket​(java.lang.String service_name)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • createSocket

        java.net.Socket createSocket​(java.lang.String service_name,
                                     java.lang.String host,
                                     int port)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • createSocket

        java.net.Socket createSocket​(java.lang.String service_name,
                                     java.net.InetAddress address,
                                     int port)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • createSocket

        java.net.Socket createSocket​(java.lang.String service_name,
                                     java.lang.String host,
                                     int port,
                                     java.net.InetAddress localAddr,
                                     int localPort)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • createSocket

        java.net.Socket createSocket​(java.lang.String service_name,
                                     java.net.InetAddress address,
                                     int port,
                                     java.net.InetAddress localAddr,
                                     int localPort)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • createServerSocket

        java.net.ServerSocket createServerSocket​(java.lang.String service_name)
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • createServerSocket

        java.net.ServerSocket createServerSocket​(java.lang.String service_name,
                                                 int port)
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • createServerSocket

        java.net.ServerSocket createServerSocket​(java.lang.String service_name,
                                                 int port,
                                                 int backlog)
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • createServerSocket

        java.net.ServerSocket createServerSocket​(java.lang.String service_name,
                                                 int port,
                                                 int backlog,
                                                 java.net.InetAddress bindAddr)
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • createSocketChannel

        default java.nio.channels.SocketChannel createSocketChannel​(java.lang.String service_name)
                                                             throws java.io.IOException
        Throws:
        java.io.IOException
      • createSocketChannel

        default java.nio.channels.SocketChannel createSocketChannel​(java.lang.String service_name,
                                                                    java.net.SocketAddress bindAddr)
                                                             throws java.io.IOException
        Throws:
        java.io.IOException
      • createServerSocketChannel

        default java.nio.channels.ServerSocketChannel createServerSocketChannel​(java.lang.String service_name)
                                                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • createServerSocketChannel

        default java.nio.channels.ServerSocketChannel createServerSocketChannel​(java.lang.String service_name,
                                                                                int port)
                                                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • createServerSocketChannel

        default java.nio.channels.ServerSocketChannel createServerSocketChannel​(java.lang.String service_name,
                                                                                int port,
                                                                                int backlog)
                                                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • createServerSocketChannel

        default java.nio.channels.ServerSocketChannel createServerSocketChannel​(java.lang.String service_name,
                                                                                int port,
                                                                                int backlog,
                                                                                java.net.InetAddress bindAddr)
                                                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • createDatagramSocket

        java.net.DatagramSocket createDatagramSocket​(java.lang.String service_name)
                                              throws java.net.SocketException
        Throws:
        java.net.SocketException
      • createDatagramSocket

        java.net.DatagramSocket createDatagramSocket​(java.lang.String service_name,
                                                     java.net.SocketAddress bindaddr)
                                              throws java.net.SocketException
        Throws:
        java.net.SocketException
      • createDatagramSocket

        java.net.DatagramSocket createDatagramSocket​(java.lang.String service_name,
                                                     int port)
                                              throws java.net.SocketException
        Throws:
        java.net.SocketException
      • createDatagramSocket

        java.net.DatagramSocket createDatagramSocket​(java.lang.String service_name,
                                                     int port,
                                                     java.net.InetAddress laddr)
                                              throws java.net.SocketException
        Throws:
        java.net.SocketException
      • createMulticastSocket

        java.net.MulticastSocket createMulticastSocket​(java.lang.String service_name)
                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • createMulticastSocket

        java.net.MulticastSocket createMulticastSocket​(java.lang.String service_name,
                                                       int port)
                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • createMulticastSocket

        java.net.MulticastSocket createMulticastSocket​(java.lang.String service_name,
                                                       java.net.SocketAddress bindaddr)
                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • close

        void close​(java.net.Socket sock)
            throws java.io.IOException
        Throws:
        java.io.IOException
      • close

        void close​(java.net.ServerSocket sock)
            throws java.io.IOException
        Throws:
        java.io.IOException
      • close

        void close​(java.net.DatagramSocket sock)
      • close

        default void close​(java.nio.channels.SocketChannel channel)
      • close

        default void close​(java.nio.channels.ServerSocketChannel channel)