# ServerSocketFactory

public abstract class **ServerSocketFactory** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  

|---|---|---|
| Known Direct Subclasses [SSLServerSocketFactory](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLServerSocketFactory.html) |---|---| | [SSLServerSocketFactory](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLServerSocketFactory.html) | `SSLServerSocketFactory`s create `SSLServerSocket`s. | |||

This class creates server sockets. It may be subclassed by other
factories, which create particular types of server sockets. This
provides a general framework for the addition of public socket-level
functionality. It is the server side analogue of a socket factory,
and similarly provides a way to capture a variety of policies related
to the sockets being constructed.

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.

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/SocketFactory.html`

### Protected Constructor Summary

|---|---|
|   | [ServerSocketFactory](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ServerSocketFactory.html#ServerSocketFactory())() Creates a server socket factory. |

### Public Method Summary

|---|---|
| abstract [ServerSocket](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ServerSocket.html) | [createServerSocket](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ServerSocketFactory.html#createServerSocket(int))(int port) Returns a server socket bound to the specified port. |
| [ServerSocket](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ServerSocket.html) | [createServerSocket](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ServerSocketFactory.html#createServerSocket())() Returns an unbound server socket. |
| abstract [ServerSocket](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ServerSocket.html) | [createServerSocket](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ServerSocketFactory.html#createServerSocket(int,%20int,%20java.net.InetAddress))(int port, int backlog, [InetAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/InetAddress.html) ifAddress) Returns a server socket bound to the specified port, with a specified listen backlog and local IP. |
| abstract [ServerSocket](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ServerSocket.html) | [createServerSocket](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ServerSocketFactory.html#createServerSocket(int,%20int))(int port, int backlog) Returns a server socket bound to the specified port, and uses the specified connection backlog. |
| static [ServerSocketFactory](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ServerSocketFactory.html) | [getDefault](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ServerSocketFactory.html#getDefault())() Returns a copy of the environment's default socket factory. |

### Inherited Method Summary

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

## Protected Constructors

#### protected
**ServerSocketFactory**
()

Creates a server socket factory.

## Public Methods

#### public abstract [ServerSocket](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ServerSocket.html)
**createServerSocket**
(int port)

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.


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.

##### Parameters

| port | the port to listen to |
|---|---|

##### Returns

- the `ServerSocket`

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | for networking errors |
| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and its `checkListen` method doesn't allow the operation. |
| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityManager.html#checkListen(int)`
- `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ServerSocket.html#ServerSocket(int)`

#### public [ServerSocket](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ServerSocket.html)
**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](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | if the socket cannot be created |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ServerSocket.html#bind(java.net.SocketAddress)`
- `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ServerSocket.html#bind(java.net.SocketAddress,%20int)`
- `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ServerSocket.html#ServerSocket()`

#### public abstract [ServerSocket](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ServerSocket.html)
**createServerSocket**
(int port, int backlog, [InetAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/InetAddress.html) ifAddress)

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 a `ServerSocket` that will only accept connect
requests to one of its addresses. If `ifAddress` 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.


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.

##### Parameters

| port | the port to listen to |
| backlog | how many connections are queued |
| ifAddress | the network interface address to use |
|---|---|

##### Returns

- the `ServerSocket`

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | for networking errors |
| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and its `checkListen` method doesn't allow the operation. |
| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityManager.html#checkListen(int)`
- `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ServerSocket.html#ServerSocket(int,%20int,%20java.net.InetAddress)`

#### public abstract [ServerSocket](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ServerSocket.html)
**createServerSocket**
(int port, int backlog)

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.


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.

##### Parameters

| port | the port to listen to |
| backlog | how many connections are queued |
|---|---|

##### Returns

- the `ServerSocket`

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | for networking errors |
| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and its `checkListen` method doesn't allow the operation. |
| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityManager.html#checkListen(int)`
- `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/ServerSocket.html#ServerSocket(int,%20int)`

#### public static [ServerSocketFactory](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ServerSocketFactory.html)
**getDefault**
()

Returns a copy of the environment's default socket factory.

##### Returns

- the `ServerSocketFactory`