public class ServerSocketFactory
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
(package private) class |
ServerSocketFactory.PrServerSocket |
Modifier and Type | Field and Description |
---|---|
private static ServerSocketFactory |
defaultFactory |
private PortRange |
portRange |
Modifier | Constructor and Description |
---|---|
protected |
ServerSocketFactory() |
Modifier and Type | Method and Description |
---|---|
java.net.ServerSocket |
createServerSocket(int port)
Creates a server socket on a specified port.
|
private java.net.ServerSocket |
createServerSocket(int backlog,
java.net.InetAddress binAddr)
Tries to find first available port within the port range specified.
|
java.net.ServerSocket |
createServerSocket(int port,
int backlog)
Creates a server socket on a specified port.
|
java.net.ServerSocket |
createServerSocket(int port,
int backlog,
java.net.InetAddress bindAddr)
Create a server with the specified port, listen backlog, and
local IP address to bind to.
|
static ServerSocketFactory |
getDefault()
Returns the default instance of this class.
|
private static ServerSocketFactory defaultFactory
private PortRange portRange
public static ServerSocketFactory getDefault()
public java.net.ServerSocket createServerSocket(int port) throws java.io.IOException
0
creates a socket on any free port or if the
tcp.port.range system property is set it creates a socket
within the specified port range.
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.
port
- the port number, or 0
to use any
free port or if the tcp.port.range property set
to use any available port within the specified port
range.java.io.IOException
- if an I/O error occurs when opening the socket.public java.net.ServerSocket createServerSocket(int port, int backlog) throws java.io.IOException
0
creates a socket on any free port or if the
tcp.port.range system property is set it creates a socket
within the specified port range.
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.
port
- the port number, or 0
to use any
free port or if the tcp.port.range property set
to use any available port within the specified port
range.backlog
- the maximum length of the queue.java.io.IOException
- if an I/O error occurs when opening the socket.public java.net.ServerSocket createServerSocket(int port, int backlog, java.net.InetAddress bindAddr) throws java.io.IOException
port
- the local TCP portbacklog
- the listen backlogbindAddr
- the local InetAddress the server will bind tojava.io.IOException
- if an I/O error occurs when opening the socket.private java.net.ServerSocket createServerSocket(int backlog, java.net.InetAddress binAddr) throws java.io.IOException
java.io.IOException