Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Protected Ctors](https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#proctors) \| [Methods](https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#inhmethods)

# SSLServerSocket

` public abstract class SSLServerSocket `   
` ` ` extends https://developer.android.com/reference/java/net/ServerSocket ` ` `

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [java.net.ServerSocket](https://developer.android.com/reference/java/net/ServerSocket) ||
|   | ↳ | javax.net.ssl.SSLServerSocket |

<br />

*** ** * ** ***

This class extends `ServerSocket`s and provides secure server sockets using protocols such as the Secure Sockets Layer (SSL) or Transport Layer Security (TLS) protocols.

Instances of this class are generally created using a `SSLServerSocketFactory`. The primary function of `SSLServerSocket`s is to create `SSLSocket`s by `accept`ing connections.

`SSLServerSocket`s contain several pieces of state data which are inherited by the `SSLSocket` at socket creation. These include the enabled cipher suites and protocols, whether client authentication is necessary, and whether created sockets should begin handshaking in client or server mode. The state inherited by the created `SSLSocket` can be overriden by calling the appropriate methods.
**See also:**

- `https://developer.android.com/reference/java/net/ServerSocket`
- `https://developer.android.com/reference/javax/net/ssl/SSLSocket`

## Summary

| ### Protected constructors ||
|---|---|
| ` https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#SSLServerSocket()() ` Used only by subclasses. |
| ` https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#SSLServerSocket(int)(int port) ` Used only by subclasses. |
| ` https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#SSLServerSocket(int,%20int)(int port, int backlog) ` Used only by subclasses. |
| ` https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#SSLServerSocket(int,%20int,%20java.net.InetAddress)(int port, int backlog, https://developer.android.com/reference/java/net/InetAddress address) ` Used only by subclasses. |

| ### Public methods ||
|---|---|
| ` abstract boolean` | ` https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#getEnableSessionCreation()() ` Returns true if new SSL sessions may be established by the sockets which are created from this server socket. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#getEnabledCipherSuites()() ` Returns the list of cipher suites which are currently enabled for use by newly accepted connections. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#getEnabledProtocols()() ` Returns the names of the protocols which are currently enabled for use by the newly accepted connections. |
| ` abstract boolean` | ` https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#getNeedClientAuth()() ` Returns true if client authentication will be *required* on newly `accept`ed server-mode `SSLSocket`s. |
| ` https://developer.android.com/reference/javax/net/ssl/SSLParameters` | ` https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#getSSLParameters()() ` Returns the SSLParameters in effect for newly accepted connections. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#getSupportedCipherSuites()() ` Returns the names of the cipher suites which could be enabled for use on an SSL connection. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#getSupportedProtocols()() ` Returns the names of the protocols which could be enabled for use. |
| ` abstract boolean` | ` https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#getUseClientMode()() ` Returns true if accepted connections will be in SSL client mode. |
| ` abstract boolean` | ` https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#getWantClientAuth()() ` Returns true if client authentication will be *requested* on newly accepted server-mode connections. |
| ` abstract void` | ` https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setEnableSessionCreation(boolean)(boolean flag) ` Controls whether new SSL sessions may be established by the sockets which are created from this server socket. |
| ` abstract void` | ` https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setEnabledCipherSuites(java.lang.String[])(https://developer.android.com/reference/java/lang/String suites) ` Sets the cipher suites enabled for use by accepted connections. |
| ` abstract void` | ` https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setEnabledProtocols(java.lang.String[])(https://developer.android.com/reference/java/lang/String protocols) ` Controls which particular protocols are enabled for use by accepted connections. |
| ` abstract void` | ` https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setNeedClientAuth(boolean)(boolean need) ` Controls whether `accept`ed server-mode `SSLSockets` will be initially configured to *require* client authentication. |
| ` void` | ` https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setSSLParameters(javax.net.ssl.SSLParameters)(https://developer.android.com/reference/javax/net/ssl/SSLParameters params) ` Applies SSLParameters to newly accepted connections. |
| ` abstract void` | ` https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setUseClientMode(boolean)(boolean mode) ` Controls whether accepted connections are in the (default) SSL server mode, or the SSL client mode. |
| ` abstract void` | ` https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setWantClientAuth(boolean)(boolean want) ` Controls whether `accept`ed server-mode `SSLSockets` will be initially configured to *request* client authentication. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#toString()() ` Returns the implementation address and implementation port of this socket as a `String`. |

### Inherited methods

From class ` https://developer.android.com/reference/java/net/ServerSocket ` ` https://developer.android.com/reference/java/net/Socket` ` https://developer.android.com/reference/java/net/ServerSocket#accept()() `

Listens for a connection to be made to this socket and accepts it.
` void` ` https://developer.android.com/reference/java/net/ServerSocket#bind(java.net.SocketAddress,%20int)(https://developer.android.com/reference/java/net/SocketAddress endpoint, int backlog) `

Binds the `ServerSocket` to a specific address (IP address and port number).
` void` ` https://developer.android.com/reference/java/net/ServerSocket#bind(java.net.SocketAddress)(https://developer.android.com/reference/java/net/SocketAddress endpoint) `

Binds the `ServerSocket` to a specific address (IP address and port number).
` void` ` https://developer.android.com/reference/java/net/ServerSocket#close()() `

Closes this socket.
` https://developer.android.com/reference/java/nio/channels/ServerSocketChannel` ` https://developer.android.com/reference/java/net/ServerSocket#getChannel()() `

Returns the unique `https://developer.android.com/reference/java/nio/channels/ServerSocketChannel` object associated with this socket, if any.
` https://developer.android.com/reference/java/net/InetAddress` ` https://developer.android.com/reference/java/net/ServerSocket#getInetAddress()() `

Returns the local address of this server socket.
` int` ` https://developer.android.com/reference/java/net/ServerSocket#getLocalPort()() `

Returns the port number on which this socket is listening.
` https://developer.android.com/reference/java/net/SocketAddress` ` https://developer.android.com/reference/java/net/ServerSocket#getLocalSocketAddress()() `

Returns the address of the endpoint this socket is bound to.
` <T> T` ` https://developer.android.com/reference/java/net/ServerSocket#getOption(java.net.SocketOption<T>)(https://developer.android.com/reference/java/net/SocketOption<T> name) `

Returns the value of a socket option.
` int` ` https://developer.android.com/reference/java/net/ServerSocket#getReceiveBufferSize()() `

Gets the value of the `https://developer.android.com/reference/java/net/SocketOptions#SO_RCVBUF` option for this `ServerSocket`, that is the proposed buffer size that will be used for Sockets accepted from this `ServerSocket`.
` boolean` ` https://developer.android.com/reference/java/net/ServerSocket#getReuseAddress()() `

Tests if `https://developer.android.com/reference/java/net/SocketOptions#SO_REUSEADDR` is enabled.
` int` ` https://developer.android.com/reference/java/net/ServerSocket#getSoTimeout()() `

Retrieve setting for `https://developer.android.com/reference/java/net/SocketOptions#SO_TIMEOUT`.
` final void` ` https://developer.android.com/reference/java/net/ServerSocket#implAccept(java.net.Socket)(https://developer.android.com/reference/java/net/Socket s) `

Subclasses of ServerSocket use this method to override accept() to return their own subclass of socket.
` boolean` ` https://developer.android.com/reference/java/net/ServerSocket#isBound()() `

Returns the binding state of the ServerSocket.
` boolean` ` https://developer.android.com/reference/java/net/ServerSocket#isClosed()() `

Returns the closed state of the ServerSocket.
` <T> https://developer.android.com/reference/java/net/ServerSocket` ` https://developer.android.com/reference/java/net/ServerSocket#setOption(java.net.SocketOption<T>,%20T)(https://developer.android.com/reference/java/net/SocketOption<T> name, T value) `

Sets the value of a socket option.
` void` ` https://developer.android.com/reference/java/net/ServerSocket#setPerformancePreferences(int,%20int,%20int)(int connectionTime, int latency, int bandwidth) `

Sets performance preferences for this ServerSocket.
` void` ` https://developer.android.com/reference/java/net/ServerSocket#setReceiveBufferSize(int)(int size) `

Sets a default proposed value for the `https://developer.android.com/reference/java/net/SocketOptions#SO_RCVBUF` option for sockets accepted from this `ServerSocket`.
` void` ` https://developer.android.com/reference/java/net/ServerSocket#setReuseAddress(boolean)(boolean on) `

Enable/disable the `https://developer.android.com/reference/java/net/SocketOptions#SO_REUSEADDR` socket option.
` void` ` https://developer.android.com/reference/java/net/ServerSocket#setSoTimeout(int)(int timeout) `

Enable/disable `https://developer.android.com/reference/java/net/SocketOptions#SO_TIMEOUT` with the specified timeout, in milliseconds.
` static void` ` https://developer.android.com/reference/java/net/ServerSocket#setSocketFactory(java.net.SocketImplFactory)(https://developer.android.com/reference/java/net/SocketImplFactory fac) `

Sets the server socket implementation factory for the application.
` https://developer.android.com/reference/java/util/Set<https://developer.android.com/reference/java/net/SocketOption<?>>` ` https://developer.android.com/reference/java/net/ServerSocket#supportedOptions()() `

Returns a set of the socket options supported by this server socket.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/net/ServerSocket#toString()() `

Returns the implementation address and implementation port of this socket as a `String`.
From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(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.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(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` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.
From interface ` https://developer.android.com/reference/java/io/Closeable ` ` abstract void` ` https://developer.android.com/reference/java/io/Closeable#close()() `

Closes this stream and releases any system resources associated with it.
From interface ` https://developer.android.com/reference/java/lang/AutoCloseable ` ` abstract void` ` https://developer.android.com/reference/java/lang/AutoCloseable#close()() `

Closes this resource, relinquishing any underlying resources.

## Protected constructors

### SSLServerSocket

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected SSLServerSocket ()
```

Used only by subclasses.

Create an unbound TCP server socket using the default authentication context.

<br />

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | if an I/O error occurs when creating the socket |

### SSLServerSocket

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected SSLServerSocket (int port)
```

Used only by subclasses.

Create a TCP server socket on a port, using the default authentication context. The connection backlog defaults to fifty connections queued up before the system starts to reject new connection requests.

A port number of `0` creates a socket on any free port.

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.

<br />

| Parameters ||
|---|---|
| `port` | `int`: the port on which to listen <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | if an I/O error occurs when creating the socket |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive. |
| `https://developer.android.com/reference/java/lang/SecurityException` | if a security manager exists and its `checkListen` method doesn't allow the operation. |

**See also:**

- `https://developer.android.com/reference/java/lang/SecurityManager#checkListen(int)`

### SSLServerSocket

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected SSLServerSocket (int port, 
                int backlog)
```

Used only by subclasses.

Create a TCP server socket on a port, using the default authentication context and a specified backlog of connections.

A port number of `0` creates a socket on any free port.

The `backlog` argument is the requested maximum number of pending connections on the socket. Its exact semantics are implementation specific. In particular, an implementation may impose a maximum length or may choose to ignore the parameter altogther. The value provided should be greater than `0`. If it is less than or equal to `0`, then an implementation specific default will be used.

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.

<br />

| Parameters ||
|---|---|
| `port` | `int`: the port on which to listen <br /> |
| `backlog` | `int`: requested maximum length of the queue of incoming connections. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | if an I/O error occurs when creating the socket |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive. |
| `https://developer.android.com/reference/java/lang/SecurityException` | if a security manager exists and its `checkListen` method doesn't allow the operation. |

**See also:**

- `https://developer.android.com/reference/java/lang/SecurityManager#checkListen(int)`

### SSLServerSocket

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected SSLServerSocket (int port, 
                int backlog, 
                InetAddress address)
```

Used only by subclasses.

Create a TCP server socket on a port, using the default authentication context and a specified backlog of connections as well as a particular specified network interface. This constructor is used on multihomed hosts, such as those used for firewalls or as routers, to control through which interface a network service is provided.

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.

A port number of `0` creates a socket on any free port.

The `backlog` argument is the requested maximum number of pending connections on the socket. Its exact semantics are implementation specific. In particular, an implementation may impose a maximum length or may choose to ignore the parameter altogther. The value provided should be greater than `0`. If it is less than or equal to `0`, then an implementation specific default will be used.

If *address* is null, it will default accepting connections on any/all local addresses.

<br />

| Parameters ||
|---|---|
| `port` | `int`: the port on which to listen <br /> |
| `backlog` | `int`: requested maximum length of the queue of incoming connections. <br /> |
| `address` | `InetAddress`: the address of the network interface through which connections will be accepted <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | if an I/O error occurs when creating the socket |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive. |
| `https://developer.android.com/reference/java/lang/SecurityException` | if a security manager exists and its `checkListen` method doesn't allow the operation. |

**See also:**

- `https://developer.android.com/reference/java/lang/SecurityManager#checkListen(int)`

## Public methods

### getEnableSessionCreation

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract boolean getEnableSessionCreation ()
```

Returns true if new SSL sessions may be established by the sockets which are created from this server socket.

<br />

| Returns ||
|---|---|
| `boolean` | true indicates that sessions may be created; this is the default. false indicates that an existing session must be resumed <br /> |

**See also:**

- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setEnableSessionCreation(boolean)`

### getEnabledCipherSuites

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract String[] getEnabledCipherSuites ()
```

Returns the list of cipher suites which are currently enabled for use by newly accepted connections.

If this list has not been explicitly modified, a system-provided default guarantees a minimum quality of service in all enabled cipher suites.

There are several reasons why an enabled cipher suite might not actually be used. For example: the server socket might not have appropriate private keys available to it or the cipher suite might be anonymous, precluding the use of client authentication, while the server socket has been told to require that sort of authentication.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | an array of cipher suites enabled <br /> |

**See also:**

- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#getSupportedCipherSuites()`
- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setEnabledCipherSuites(java.lang.String[])`

### getEnabledProtocols

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract String[] getEnabledProtocols ()
```

Returns the names of the protocols which are currently enabled for use by the newly accepted connections.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | an array of protocol names <br /> |

**See also:**

- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#getSupportedProtocols()`
- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setEnabledProtocols(java.lang.String[])`

### getNeedClientAuth

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract boolean getNeedClientAuth ()
```

Returns true if client authentication will be *required* on newly `accept`ed server-mode `SSLSocket`s.

The initial inherited setting may be overridden by calling `https://developer.android.com/reference/javax/net/ssl/SSLSocket#setNeedClientAuth(boolean)` or `https://developer.android.com/reference/javax/net/ssl/SSLSocket#setWantClientAuth(boolean)`.

<br />

| Returns ||
|---|---|
| `boolean` | true if client authentication is required, or false if no client authentication is desired. <br /> |

**See also:**

- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setNeedClientAuth(boolean)`
- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setWantClientAuth(boolean)`
- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#getWantClientAuth()`
- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setUseClientMode(boolean)`

### getSSLParameters

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SSLParameters getSSLParameters ()
```

Returns the SSLParameters in effect for newly accepted connections. The ciphersuites and protocols of the returned SSLParameters are always non-null.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/net/ssl/SSLParameters` | the SSLParameters in effect for newly accepted connections <br /> |

**See also:**

- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setSSLParameters(javax.net.ssl.SSLParameters)`

### getSupportedCipherSuites

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract String[] getSupportedCipherSuites ()
```

Returns the names of the cipher suites which could be enabled for use on an SSL connection.

Normally, only a subset of these will actually be enabled by default, since this list may include cipher suites which do not meet quality of service requirements for those defaults. Such cipher suites are useful in specialized applications.

Applications should not blindly enable all supported cipher suites. The supported cipher suites can include signaling cipher suite values that can cause connection problems if enabled inappropriately.

The proper way to use this method is to either check if a specific cipher suite is supported via `Arrays.asList(getSupportedCipherSuites()).contains(...)` or to filter a desired list of cipher suites to only the supported ones via `desiredSuiteSet.retainAll(Arrays.asList(getSupportedCipherSuites()))`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | an array of cipher suite names <br /> |

**See also:**

- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#getEnabledCipherSuites()`
- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setEnabledCipherSuites(java.lang.String[])`

### getSupportedProtocols

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract String[] getSupportedProtocols ()
```

Returns the names of the protocols which could be enabled for use.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | an array of protocol names supported <br /> |

**See also:**

- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#getEnabledProtocols()`
- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setEnabledProtocols(java.lang.String[])`

### getUseClientMode

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract boolean getUseClientMode ()
```

Returns true if accepted connections will be in SSL client mode.

<br />

| Returns ||
|---|---|
| `boolean` | true if the connection should use SSL client mode. <br /> |

**See also:**

- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setUseClientMode(boolean)`

### getWantClientAuth

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract boolean getWantClientAuth ()
```

Returns true if client authentication will be *requested* on newly accepted server-mode connections.

The initial inherited setting may be overridden by calling `https://developer.android.com/reference/javax/net/ssl/SSLSocket#setNeedClientAuth(boolean)` or `https://developer.android.com/reference/javax/net/ssl/SSLSocket#setWantClientAuth(boolean)`.

<br />

| Returns ||
|---|---|
| `boolean` | true if client authentication is requested, or false if no client authentication is desired. <br /> |

**See also:**

- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setWantClientAuth(boolean)`
- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setNeedClientAuth(boolean)`
- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#getNeedClientAuth()`
- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setUseClientMode(boolean)`

### setEnableSessionCreation

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void setEnableSessionCreation (boolean flag)
```

Controls whether new SSL sessions may be established by the sockets which are created from this server socket.

`SSLSocket`s returned from `accept()` inherit this setting.

<br />

| Parameters ||
|---|---|
| `flag` | `boolean`: true indicates that sessions may be created; this is the default. false indicates that an existing session must be resumed. <br /> |

**See also:**

- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#getEnableSessionCreation()`

### setEnabledCipherSuites

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void setEnabledCipherSuites (String[] suites)
```

Sets the cipher suites enabled for use by accepted connections.

The cipher suites must have been listed by getSupportedCipherSuites() as being supported. Following a successful call to this method, only suites listed in the `suites` parameter are enabled for use.

Suites that require authentication information which is not available in this ServerSocket's authentication context will not be used in any case, even if they are enabled.

`SSLSocket`s returned from `accept()` inherit this setting.

<br />

| Parameters ||
|---|---|
| `suites` | `String`: Names of all the cipher suites to enable <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | when one or more of ciphers named by the parameter is not supported, or when the parameter is null. |

**See also:**

- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#getSupportedCipherSuites()`
- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#getEnabledCipherSuites()`

### setEnabledProtocols

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void setEnabledProtocols (String[] protocols)
```

Controls which particular protocols are enabled for use by accepted connections.

The protocols must have been listed by getSupportedProtocols() as being supported. Following a successful call to this method, only protocols listed in the `protocols` parameter are enabled for use.

Because of the way the protocol version is negotiated, connections will only be able to use a member of the lowest set of contiguous enabled protocol versions. For example, enabling TLSv1.2 and TLSv1 will result in connections only being able to use TLSv1.

`SSLSocket`s returned from `accept()` inherit this setting.

<br />

| Parameters ||
|---|---|
| `protocols` | `String`: Names of all the protocols to enable. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | when one or more of the protocols named by the parameter is not supported or when the protocols parameter is null. |

**See also:**

- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#getEnabledProtocols()`
- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#getSupportedProtocols()`

### setNeedClientAuth

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void setNeedClientAuth (boolean need)
```

Controls whether `accept`ed server-mode `SSLSockets` will be initially configured to *require* client authentication.

A socket's client authentication setting is one of the following:

- client authentication required
- client authentication requested
- no client authentication desired

Unlike `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setWantClientAuth(boolean)`, if the accepted socket's option is set and the client chooses not to provide authentication information about itself, *the negotiations will stop and the connection will be dropped*.

Calling this method overrides any previous setting made by this method or `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setWantClientAuth(boolean)`.

The initial inherited setting may be overridden by calling `https://developer.android.com/reference/javax/net/ssl/SSLSocket#setNeedClientAuth(boolean)` or `https://developer.android.com/reference/javax/net/ssl/SSLSocket#setWantClientAuth(boolean)`.

<br />

| Parameters ||
|---|---|
| `need` | `boolean`: set to true if client authentication is required, or false if no client authentication is desired. <br /> |

**See also:**

- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#getNeedClientAuth()`
- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setWantClientAuth(boolean)`
- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#getWantClientAuth()`
- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setUseClientMode(boolean)`

### setSSLParameters

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setSSLParameters (SSLParameters params)
```

Applies SSLParameters to newly accepted connections.

This means:

- If `params.getCipherSuites()` is non-null, `setEnabledCipherSuites()` is called with that value.
- If `params.getProtocols()` is non-null, `setEnabledProtocols()` is called with that value.
- If `params.getNeedClientAuth()` or `params.getWantClientAuth()` return `true`, `setNeedClientAuth(true)` and `setWantClientAuth(true)` are called, respectively; otherwise `setWantClientAuth(false)` is called.
- If `params.getServerNames()` is non-null, the socket will configure its server names with that value.
- If `params.getSNIMatchers()` is non-null, the socket will configure its SNI matchers with that value.

<br />

<br />

| Parameters ||
|---|---|
| `params` | `SSLParameters`: the parameters <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the setEnabledCipherSuites() or the setEnabledProtocols() call fails |

**See also:**

- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#getSSLParameters()`

### setUseClientMode

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void setUseClientMode (boolean mode)
```

Controls whether accepted connections are in the (default) SSL server mode, or the SSL client mode.

Servers normally authenticate themselves, and clients are not required to do so.

In rare cases, TCP servers need to act in the SSL client mode on newly accepted connections. For example, FTP clients acquire server sockets and listen there for reverse connections from the server. An FTP client would use an SSLServerSocket in "client" mode to accept the reverse connection while the FTP server uses an SSLSocket with "client" mode disabled to initiate the connection. During the resulting handshake, existing SSL sessions may be reused.

`SSLSocket`s returned from `accept()` inherit this setting.

<br />

| Parameters ||
|---|---|
| `mode` | `boolean`: true if newly accepted connections should use SSL client mode. <br /> |

**See also:**

- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#getUseClientMode()`

### setWantClientAuth

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void setWantClientAuth (boolean want)
```

Controls whether `accept`ed server-mode `SSLSockets` will be initially configured to *request* client authentication.

A socket's client authentication setting is one of the following:

- client authentication required
- client authentication requested
- no client authentication desired

Unlike `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setNeedClientAuth(boolean)`, if the accepted socket's option is set and the client chooses not to provide authentication information about itself, *the negotiations will continue*.

Calling this method overrides any previous setting made by this method or `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setNeedClientAuth(boolean)`.

The initial inherited setting may be overridden by calling `https://developer.android.com/reference/javax/net/ssl/SSLSocket#setNeedClientAuth(boolean)` or `https://developer.android.com/reference/javax/net/ssl/SSLSocket#setWantClientAuth(boolean)`.

<br />

| Parameters ||
|---|---|
| `want` | `boolean`: set to true if client authentication is requested, or false if no client authentication is desired. <br /> |

**See also:**

- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#getWantClientAuth()`
- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setNeedClientAuth(boolean)`
- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#getNeedClientAuth()`
- `https://developer.android.com/reference/javax/net/ssl/SSLServerSocket#setUseClientMode(boolean)`

### toString

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String toString ()
```

Returns the implementation address and implementation port of this socket as a `String`.

If there is a security manager set, its `checkConnect` method is called with the local address and `-1` as its arguments to see if the operation is allowed. If the operation is not allowed, an `InetAddress` representing the `https://developer.android.com/reference/java/net/InetAddress#getLoopbackAddress()` address is returned as the implementation address.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string representation of this socket. <br /> |