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 ServerSocketcreateServerSocket(int port) Returns a server socket bound to the specified port.abstract ServerSocketcreateServerSocket(int port, int backlog) Returns a server socket bound to the specified port, and uses the specified connection backlog.abstract ServerSocketcreateServerSocket(int port, int backlog, InetAddress ifAddress) Returns a server socket bound to the specified port, with a specified listen backlog and local IP.static ServerSocketFactoryReturns a copy of the environment's default socket factory.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
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
backlogargument 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
ifAddressargument can be used on a multi-homed host for aServerSocketthat will only accept connect requests to one of its addresses. IfifAddressis 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
backlogargument 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:
-