SSLServerSocketFactory
public abstract class ServerSocketFactory extends Object
Like socket factories, server Socket factory instances have methods used to create sockets. There is also an environment specific default server socket factory; frameworks will often use their own customized factory.
Modifier | Constructor | Description |
---|---|---|
protected |
Creates a server socket factory. |
Modifier and Type | Method | Description |
---|---|---|
ServerSocket |
createServerSocket() |
Returns an unbound server socket. |
abstract ServerSocket |
createServerSocket |
Returns a server socket bound to the specified port. |
abstract ServerSocket |
createServerSocket |
Returns a server socket bound to the specified port, and uses the specified connection backlog. |
abstract ServerSocket |
createServerSocket |
Returns a server socket bound to the specified port, with a specified listen backlog and local IP. |
static ServerSocketFactory |
getDefault() |
Returns a copy of the environment's default socket factory. |
protected ServerSocketFactory()
public static ServerSocketFactory getDefault()
ServerSocketFactory
public ServerSocket createServerSocket() throws IOException
IOException
- if the socket cannot be createdpublic abstract ServerSocket createServerSocket(int port) throws IOException
If there is a security manager, its checkListen
method is called with the port
argument as its argument to ensure the operation is allowed. This could result in a SecurityException.
port
- the port to listen toServerSocket
IOException
- for networking errorsSecurityException
- if a security manager exists and its checkListen
method doesn't allow the operation.IllegalArgumentException
- if the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive.public abstract ServerSocket createServerSocket(int port, int backlog) throws IOException
The backlog
argument must be a positive value greater than 0. If the value passed if equal or less than 0, then the default value will be assumed.
If there is a security manager, its checkListen
method is called with the port
argument as its argument to ensure the operation is allowed. This could result in a SecurityException.
port
- the port to listen tobacklog
- how many connections are queuedServerSocket
IOException
- for networking errorsSecurityException
- if a security manager exists and its checkListen
method doesn't allow the operation.IllegalArgumentException
- if the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive.public abstract ServerSocket createServerSocket(int port, int backlog, InetAddress ifAddress) throws IOException
The ifAddress
argument can be used on a multi-homed host for a ServerSocket
that will only accept connect requests to one of its addresses. If ifAddress
is null, it will accept connections on all local addresses. The socket is configured with the socket options (such as accept timeout) given to this factory.
The backlog
argument must be a positive value greater than 0. If the value passed if equal or less than 0, then the default value will be assumed.
If there is a security manager, its checkListen
method is called with the port
argument as its argument to ensure the operation is allowed. This could result in a SecurityException.
port
- the port to listen tobacklog
- how many connections are queuedifAddress
- the network interface address to useServerSocket
IOException
- for networking errorsSecurityException
- if a security manager exists and its checkListen
method doesn't allow the operation.IllegalArgumentException
- if the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive.
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.base/javax/net/ServerSocketFactory.html