ServerSocket.ServerSocket
Class Overview | Class Members |
This Package |
All Packages
public ServerSocket( int port ) throws IOException
Parameters
- port
- the port number, or 0 to use any
free port.
Description
Creates a server socket on a specified port. A port of
0 creates a socket on any free port.
The maximum queue length for incoming connection indications (a
request to connect) is set to 50. 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.
Exceptions
IOException
if an I/O error occurs when opening the socket.
See Also
SocketImpl, createSocketImpl, setSocketFactory
public ServerSocket( int port,
int backlog ) throws IOException
Parameters
- port
- the specified port, or 0 to use
any free port.
- backlog
- the maximum length of the queue.
Description
Creates a server socket and binds it to the specified local port
number. 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 count 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.
Exceptions
IOException
if an I/O error occurs when opening the socket.
See Also
SocketImpl, createSocketImpl, setSocketFactory
public ServerSocket( int port,
int backlog,
InetAddress bindAddr ) throws IOException
Parameters
- port
- the local TCP port
- backlog
- the listen backlog
- bindAddr
- the local InetAddress the server will bind to
Description
Create a server with the specified port, listen backlog, and
local IP address to bind to. The bindAddr argument
can be used on a multi-homed host for a ServerSocket that
will only accept connect requests to one of its addresses.
If bindAddr is null, it will default accepting
connections on any/all local addresses.
The port must be between 0 and 65535, inclusive.
See Also
SocketConstants, SocketOption, SocketImpl, 1