APIdia Launch Partner
Top Description Fields Constructors Methods
javax.net

public abstract Class ServerSocketFactory

Additional top-level class in compilation unit: DefaultServerSocketFactory.

extends Object
Class Inheritance
Known Direct Subclasses
javax.net.DefaultServerSocketFactory, javax.net.ssl.SSLServerSocketFactory
Imports
java.io.IOException, java.net.InetAddress, .ServerSocket, .SocketException

This class creates server sockets. It may be subclassed by other factories, which create particular types of server sockets. This provides a general framework for the addition of public socket-level functionality. It is the server side analogue of a socket factory, and similarly provides a way to capture a variety of policies related to the sockets being constructed.

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.

Author
David Brownell
Since
1.4
See Also
SocketFactory

Field Summary

Modifier and TypeField and Description
private static ServerSocketFactory

Constructor Summary

AccessConstructor and Description
protected
ServerSocketFactory()

Creates a server socket factory.

Method Summary

Modifier and TypeMethod and Description
public ServerSocket

Returns:

the unbound socket
createServerSocket
()

Returns an unbound server socket.

public abstract ServerSocket

Returns:

the ServerSocket
createServerSocket
(int
the port to listen to
port
)

Returns a server socket bound to the specified port.

public abstract ServerSocket

Returns:

the ServerSocket
createServerSocket
(int
the port to listen to
port
,
int
how many connections are queued
backlog
)

Returns a server socket bound to the specified port, and uses the specified connection backlog.

public abstract ServerSocket

Returns:

the ServerSocket
createServerSocket
(int
the port to listen to
port
,
int
how many connections are queued
backlog
,
InetAddress
the network interface address to use
ifAddress
)

Returns a server socket bound to the specified port, with a specified listen backlog and local IP.

public static ServerSocketFactory

Returns:

the ServerSocketFactory
getDefault
()

Returns a copy of the environment's default socket factory.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

theFactoryback to summary
private static ServerSocketFactory theFactory

Constructor Detail

ServerSocketFactoryback to summary
protected ServerSocketFactory()

Creates a server socket factory.

Method Detail

createServerSocketback to summary
public ServerSocket createServerSocket() throws IOException

Returns an unbound server socket. The socket is configured with the socket options (such as accept timeout) given to this factory.

Returns:ServerSocket

the unbound socket

Exceptions
IOException:
if the socket cannot be created
See Also
java.net.ServerSocket#bind(java.net.SocketAddress), java.net.ServerSocket#bind(java.net.SocketAddress, int), java.net.ServerSocket#ServerSocket()
createServerSocketback to summary
public abstract ServerSocket createServerSocket(int port) throws IOException

Returns a server socket bound to the specified port. The socket is configured with the socket options (such as accept timeout) given to this factory.

Parameters
port:int

the port to listen to

Returns:ServerSocket

the ServerSocket

Exceptions
IOException:
for networking errors
IllegalArgumentException:
if the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive.
See Also
java.net.ServerSocket#ServerSocket(int)
createServerSocketback to summary
public abstract ServerSocket createServerSocket(int port, int backlog) throws IOException

Returns a server socket bound to the specified port, and uses the specified connection backlog. 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.

Parameters
port:int

the port to listen to

backlog:int

how many connections are queued

Returns:ServerSocket

the ServerSocket

Exceptions
IOException:
for networking errors
IllegalArgumentException:
if the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive.
See Also
java.net.ServerSocket#ServerSocket(int, int)
createServerSocketback to summary
public abstract ServerSocket createServerSocket(int port, int backlog, InetAddress ifAddress) throws IOException

Returns a server socket bound to the specified port, with a specified listen backlog and local IP.

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.

Parameters
port:int

the port to listen to

backlog:int

how many connections are queued

ifAddress:InetAddress

the network interface address to use

Returns:ServerSocket

the ServerSocket

Exceptions
IOException:
for networking errors
IllegalArgumentException:
if the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive.
See Also
java.net.ServerSocket#ServerSocket(int, int, java.net.InetAddress)
getDefaultback to summary
public static ServerSocketFactory getDefault()

Returns a copy of the environment's default socket factory.

Returns:ServerSocketFactory

the ServerSocketFactory