Class ServerSocketFactory
- Direct Known Subclasses:
SSLServerSocketFactory
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.
- Since:
- 1.4
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns an unbound server socket.abstract ServerSocket
createServerSocket
(int port) Returns a server socket bound to the specified port.abstract ServerSocket
createServerSocket
(int port, int backlog) Returns a server socket bound to the specified port, and uses the specified connection backlog.abstract ServerSocket
createServerSocket
(int port, int backlog, InetAddress ifAddress) Returns a server socket bound to the specified port, with a specified listen backlog and local IP.static ServerSocketFactory
Returns a copy of the environment's default socket factory.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Modifier and TypeMethodDescriptionprotected Object
clone()
Creates and returns a copy of this object.boolean
Indicates whether some other object is "equal to" this one.protected void
finalize()
Deprecated, for removal: This API element is subject to removal in a future version.Finalization is deprecated and subject to removal in a future release.final Class
<?> getClass()
Returns the runtime class of thisObject
.int
hashCode()
Returns a hash code value for this object.final void
notify()
Wakes up a single thread that is waiting on this object's monitor.final void
Wakes up all threads that are waiting on this object's monitor.toString()
Returns a string representation of the object.final void
wait()
Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final void
wait
(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.final void
wait
(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Constructor Details
-
ServerSocketFactory
protected ServerSocketFactory()Creates a server socket factory.
-
-
Method Details
-
getDefault
Returns a copy of the environment's default socket factory.- Returns:
- the
ServerSocketFactory
-
createServerSocket
Returns an unbound server socket. The socket is configured with the socket options (such as accept timeout) given to this factory.- Returns:
- the unbound socket
- Throws:
IOException
- if the socket cannot be created- See Also:
-
createServerSocket
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
- the port to listen to- Returns:
- the
ServerSocket
- Throws:
IOException
- for networking errorsIllegalArgumentException
- if the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive.- See Also:
-
createServerSocket
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
- the port to listen tobacklog
- how many connections are queued- Returns:
- the
ServerSocket
- Throws:
IOException
- for networking errorsIllegalArgumentException
- if the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive.- See Also:
-
createServerSocket
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 aServerSocket
that will only accept connect requests to one of its addresses. IfifAddress
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
- the port to listen tobacklog
- how many connections are queuedifAddress
- the network interface address to use- Returns:
- the
ServerSocket
- Throws:
IOException
- for networking errorsIllegalArgumentException
- if the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive.- See Also:
-