Creates a server socket and binds it to the specified local port
number, with the specified backlog.
A port number of
0
creates a socket on any
free port.
The maximum queue length for incoming connection indications (a
request to connect) is set to the backlog
parameter. If
a connection indication arrives when the queue is full, the
connection is refused.
If the application has specified a server socket factory, that
factory's createSocketImpl
method is called to create
the actual socket implementation. Otherwise a "plain" socket is created.
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.
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 - the specified port, or 0
to use
any free port.
- backlog - the maximum length of the queue.
Throws:
- IOException - if an I/O error occurs when opening the socket.
- SecurityException - if a security manager exists and its checkListen
method doesn't allow the operation.
See Also:
SocketImpl
,
SocketImplFactory.createSocketImpl()
,
ServerSocket.setSocketFactory(java.net.SocketImplFactory)
,
SecurityManager.checkListen(int)
,