Package javax.net

Class ServerSocketFactory

java.lang.Object
javax.net.ServerSocketFactory
Direct Known Subclasses:
SSLServerSocketFactory

public abstract class ServerSocketFactory
extends Object
This abstract class defines methods to create server sockets. It can be subclassed to create specific server socket types.
  • Constructor Details

    • ServerSocketFactory

      protected ServerSocketFactory()
      Creates a new ServerSocketFactory instance.
  • Method Details

    • getDefault

      public static ServerSocketFactory getDefault()
      Gets the default server socket factory of the system which can be used to create new server sockets without creating a subclass of this factory.
      Returns:
      the system default server socket factory.
    • createServerSocket

      public ServerSocket createServerSocket() throws IOException
      Creates a new server socket which is not bound to any local address. This method has to be overridden by a subclass otherwise a SocketException is thrown.
      Returns:
      the created unbound server socket.
      Throws:
      IOException - if an error occurs while creating a new server socket.
    • createServerSocket

      public abstract ServerSocket createServerSocket​(int port) throws IOException
      Creates a new server socket which is bound to the given port with a maximum backlog of 50 unaccepted connections.
      Parameters:
      port - the port on which the created socket has to listen.
      Returns:
      the created bound server socket.
      Throws:
      IOException - if an error occurs while creating a new server socket.
    • createServerSocket

      public abstract ServerSocket createServerSocket​(int port, int backlog) throws IOException
      Creates a new server socket which is bound to the given port and configures its maximum of queued connections.
      Parameters:
      port - the port on which the created socket has to listen.
      backlog - the maximum number of unaccepted connections. Passing 0 or a negative value yields the default backlog of 50.
      Returns:
      the created bound server socket.
      Throws:
      IOException - if an error occurs while creating a new server socket.
    • createServerSocket

      public abstract ServerSocket createServerSocket​(int port, int backlog, InetAddress iAddress) throws IOException
      Creates a new server socket which is bound to the given address on the specified port and configures its maximum of queued connections.
      Parameters:
      port - the port on which the created socket has to listen.
      backlog - the maximum number of unaccepted connections. Passing 0 or a negative value yields the default backlog of 50.
      iAddress - the address of the network interface which is used by the created socket.
      Returns:
      the created bound server socket.
      Throws:
      IOException - if an error occurs while creating a new server socket.