# SSLSocket

public abstract class **SSLSocket** extends [Socket](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html)  
This class extends `Socket`s and provides secure
socket using protocols such as the "Secure
Sockets Layer" (SSL) or IETF "Transport Layer Security" (TLS) protocols.


Such sockets are normal stream sockets, but they
add a layer of security protections over the underlying network transport
protocol, such as TCP. Those protections include:

- *Integrity Protection*. SSL protects against modification of messages by an active wiretapper.
- *Authentication*. In most modes, SSL provides peer authentication. Servers are usually authenticated, and clients may be authenticated as requested by servers.
- *Confidentiality (Privacy Protection)*. In most modes, SSL encrypts data being sent between client and server. This protects the confidentiality of data, so that passive wiretappers won't see sensitive data such as financial information or personal information of many kinds.

These kinds of protection are specified by a "cipher suite", which
is a combination of cryptographic algorithms used by a given SSL connection.
During the negotiation process, the two endpoints must agree on
a ciphersuite that is available in both environments.
If there is no such suite in common, no SSL connection can
be established, and no data can be exchanged.

The cipher suite used is established by a negotiation process
called "handshaking". The goal of this
process is to create or rejoin a "session", which may protect many
connections over time. After handshaking has completed, you can access
session attributes by using the *getSession* method.
The initial handshake on this connection can be initiated in
one of three ways:

- calling `startHandshake` which explicitly begins handshakes, or
- any attempt to read or write application data on this socket causes an implicit handshake, or
- a call to `getSession` tries to set up a session if there is no currently valid session, and an implicit handshake is done.

If handshaking fails for any reason, the `SSLSocket`
is closed, and no further communications can be done.

There are two groups of cipher suites which you will need to know
about when managing cipher suites:

- *Supported* cipher suites: all the suites which are supported by the SSL implementation. This list is reported using *getSupportedCipherSuites*.
- *Enabled* cipher suites, which may be fewer than the full set of supported suites. This group is set using the *setEnabledCipherSuites* method, and queried using the *getEnabledCipherSuites* method. Initially, a default set of cipher suites will be enabled on a new socket that represents the minimum suggested configuration.

Implementation defaults require that only cipher
suites which authenticate servers and provide confidentiality
be enabled by default.
Only if both sides explicitly agree to unauthenticated and/or
non-private (unencrypted) communications will such a ciphersuite be
selected.

When `SSLSocket`s are first created, no handshaking
is done so that applications may first set their communication
preferences: what cipher suites to use, whether the socket should be
in client or server mode, etc.
However, security is always provided by the time that application data
is sent over the connection.

You may register to receive event notification of handshake
completion. This involves
the use of two additional classes. *HandshakeCompletedEvent*
objects are passed to *HandshakeCompletedListener* instances,
which are registered by users of this API.

`SSLSocket`s are created by `SSLSocketFactory`s,
or by `accept`ing a connection from a
`SSLServerSocket`.

A SSL socket must choose to operate in the client or server mode.
This will determine who begins the handshaking process, as well
as which messages should be sent by each party. Each
connection must have one client and one server, or handshaking
will not progress properly. Once the initial handshaking has started, a
socket can not switch between client and server modes, even when
performing renegotiations.

### Default configuration for different Android versions

`SSLSocket` instances obtained from default `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocketFactory.html`,
`https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLServerSocketFactory.html`, and `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLContext.html` are configured as follows:


#### Protocols

Client socket:

| Protocol | Supported (API Levels) | Enabled by default (API Levels) |
|---|---|---|
| SSLv3 | 1--25 | 1--22 |
| TLSv1 | 1+ | 1+ |
| TLSv1.1 | 16+ | 20+ |
| TLSv1.2 | 16+ | 20+ |

Server socket:

| Protocol | Supported (API Levels) | Enabled by default (API Levels) |
|---|---|---|
| SSLv3 | 1--25 | 1--22 |
| TLSv1 | 1+ | 1+ |
| TLSv1.1 | 16+ | 16+ |
| TLSv1.2 | 16+ | 16+ |

#### Cipher suites

Methods that operate with cipher suite names (for example,
`https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#getSupportedCipherSuites()`,
`https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#setEnabledCipherSuites(java.lang.String[])`) have used
standard names for cipher suites since API Level 9, as listed in the table
below. Prior to API Level 9, non-standard (OpenSSL) names had been used (see
the table following this table).

| Cipher suite | Supported (API Levels) | Enabled by default (API Levels) |
|---|---|---|
| SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA | 9-22 | 9-19 |
| SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA | 9-22 | 9-19 |
| SSL_DHE_DSS_WITH_DES_CBC_SHA | 9-22 | 9-19 |
| SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA | 9-22 | 9-19 |
| SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA | 9-22 | 9-19 |
| SSL_DHE_RSA_WITH_DES_CBC_SHA | 9-22 | 9-19 |
| SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA | 9-22 |   |
| SSL_DH_anon_EXPORT_WITH_RC4_40_MD5 | 9-22 |   |
| SSL_DH_anon_WITH_3DES_EDE_CBC_SHA | 9-22 |   |
| SSL_DH_anon_WITH_DES_CBC_SHA | 9-22 |   |
| SSL_DH_anon_WITH_RC4_128_MD5 | 9-22 |   |
| SSL_RSA_EXPORT_WITH_DES40_CBC_SHA | 9-22 | 9-19 |
| SSL_RSA_EXPORT_WITH_RC4_40_MD5 | 9-22 | 9-19 |
| SSL_RSA_WITH_3DES_EDE_CBC_SHA | 9+ | 9-19 |
| SSL_RSA_WITH_DES_CBC_SHA | 9-22 | 9-19 |
| SSL_RSA_WITH_NULL_MD5 | 9-22 |   |
| SSL_RSA_WITH_NULL_SHA | 9-22 |   |
| SSL_RSA_WITH_RC4_128_MD5 | 9-25 | 9-19 |
| SSL_RSA_WITH_RC4_128_SHA | 9-25 | 9-23 |
| TLS_DHE_DSS_WITH_AES_128_CBC_SHA | 9-22 | 9-22 |
| TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 | 20-22 |   |
| TLS_DHE_DSS_WITH_AES_128_GCM_SHA256 | 20-22 |   |
| TLS_DHE_DSS_WITH_AES_256_CBC_SHA | 9-22 | 11-22 |
| TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 | 20-22 |   |
| TLS_DHE_DSS_WITH_AES_256_GCM_SHA384 | 20-22 |   |
| TLS_DHE_RSA_WITH_AES_128_CBC_SHA | 9-25 | 9-25 |
| TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 | 20-25 |   |
| TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 | 20-25 | 20-25 |
| TLS_DHE_RSA_WITH_AES_256_CBC_SHA | 9-25 | 11-25 |
| TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 | 20-25 |   |
| TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 | 20-25 | 20-25 |
| TLS_DH_anon_WITH_AES_128_CBC_SHA | 9-22 |   |
| TLS_DH_anon_WITH_AES_128_CBC_SHA256 | 20-22 |   |
| TLS_DH_anon_WITH_AES_128_GCM_SHA256 | 20-22 |   |
| TLS_DH_anon_WITH_AES_256_CBC_SHA | 9-22 |   |
| TLS_DH_anon_WITH_AES_256_CBC_SHA256 | 20-22 |   |
| TLS_DH_anon_WITH_AES_256_GCM_SHA384 | 20-22 |   |
| TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA | 11-22 | 11-19 |
| TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA | 11+ | 11+ |
| TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 | 20+ |   |
| TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 | 20+ | 20+ |
| TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA | 11+ | 11+ |
| TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 | 20+ |   |
| TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 | 20+ | 20+ |
| TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 | 24+ | 24+ |
| TLS_ECDHE_ECDSA_WITH_NULL_SHA | 11-22 |   |
| TLS_ECDHE_ECDSA_WITH_RC4_128_SHA | 11-25 | 11-23 |
| TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA | 21+ | 21+ |
| TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA | 21+ | 21+ |
| TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256 | 24+ | 24+ |
| TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA | 11-22 | 11-19 |
| TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA | 11+ | 11+ |
| TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 | 20+ |   |
| TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 | 20+ | 20+ |
| TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA | 11+ | 11+ |
| TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 | 20+ |   |
| TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 | 20+ | 20+ |
| TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 | 24+ | 24+ |
| TLS_ECDHE_RSA_WITH_NULL_SHA | 11-22 |   |
| TLS_ECDHE_RSA_WITH_RC4_128_SHA | 11-25 | 11-23 |
| TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA | 11-22 | 11-19 |
| TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA | 11-22 | 11-19 |
| TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 | 20-22 |   |
| TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 | 20-22 |   |
| TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA | 11-22 | 11-19 |
| TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 | 20-22 |   |
| TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 | 20-22 |   |
| TLS_ECDH_ECDSA_WITH_NULL_SHA | 11-22 |   |
| TLS_ECDH_ECDSA_WITH_RC4_128_SHA | 11-22 | 11-19 |
| TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA | 11-22 | 11-19 |
| TLS_ECDH_RSA_WITH_AES_128_CBC_SHA | 11-22 | 11-19 |
| TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 | 20-22 |   |
| TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 | 20-22 |   |
| TLS_ECDH_RSA_WITH_AES_256_CBC_SHA | 11-22 | 11-19 |
| TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 | 20-22 |   |
| TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 | 20-22 |   |
| TLS_ECDH_RSA_WITH_NULL_SHA | 11-22 |   |
| TLS_ECDH_RSA_WITH_RC4_128_SHA | 11-22 | 11-19 |
| TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA | 11-22 |   |
| TLS_ECDH_anon_WITH_AES_128_CBC_SHA | 11-22 |   |
| TLS_ECDH_anon_WITH_AES_256_CBC_SHA | 11-22 |   |
| TLS_ECDH_anon_WITH_NULL_SHA | 11-22 |   |
| TLS_ECDH_anon_WITH_RC4_128_SHA | 11-22 |   |
| TLS_EMPTY_RENEGOTIATION_INFO_SCSV | 11+ | 11+ |
| TLS_FALLBACK_SCSV | 21+ |   |
| TLS_PSK_WITH_3DES_EDE_CBC_SHA | 21-22 |   |
| TLS_PSK_WITH_AES_128_CBC_SHA | 21+ | 21+ |
| TLS_PSK_WITH_AES_256_CBC_SHA | 21+ | 21+ |
| TLS_PSK_WITH_RC4_128_SHA | 21-25 |   |
| TLS_RSA_WITH_AES_128_CBC_SHA | 9+ | 9+ |
| TLS_RSA_WITH_AES_128_CBC_SHA256 | 20+ |   |
| TLS_RSA_WITH_AES_128_GCM_SHA256 | 20+ | 20+ |
| TLS_RSA_WITH_AES_256_CBC_SHA | 9+ | 11+ |
| TLS_RSA_WITH_AES_256_CBC_SHA256 | 20+ |   |
| TLS_RSA_WITH_AES_256_GCM_SHA384 | 20+ | 20+ |
| TLS_RSA_WITH_NULL_SHA256 | 20-22 |   |

*NOTE* : PSK cipher suites are enabled by default only if the `SSLContext` through
which the socket was created has been initialized with a `PSKKeyManager`.

API Levels 1 to 8 use OpenSSL names for cipher suites. The table below
lists these OpenSSL names and their corresponding standard names used in API
Levels 9 and newer.

| OpenSSL cipher suite | Standard cipher suite | Supported (API Levels) | Enabled by default (API Levels) |
|---|---|---|---|
| AES128-SHA | TLS_RSA_WITH_AES_128_CBC_SHA | 1+ | 1+ |
| AES256-SHA | TLS_RSA_WITH_AES_256_CBC_SHA | 1+ | 1--8, 11+ |
| DES-CBC-MD5 | SSL_CK_DES_64_CBC_WITH_MD5 | 1--8 | 1--8 |
| DES-CBC-SHA | SSL_RSA_WITH_DES_CBC_SHA | 1--22 | 1--19 |
| DES-CBC3-MD5 | SSL_CK_DES_192_EDE3_CBC_WITH_MD5 | 1--8 | 1--8 |
| DES-CBC3-SHA | SSL_RSA_WITH_3DES_EDE_CBC_SHA | 1+ | 1--19 |
| DHE-DSS-AES128-SHA | TLS_DHE_DSS_WITH_AES_128_CBC_SHA | 1--22 | 1--22 |
| DHE-DSS-AES256-SHA | TLS_DHE_DSS_WITH_AES_256_CBC_SHA | 1--22 | 1--8, 11--22 |
| DHE-RSA-AES128-SHA | TLS_DHE_RSA_WITH_AES_128_CBC_SHA | 1+ | 1+ |
| DHE-RSA-AES256-SHA | TLS_DHE_RSA_WITH_AES_256_CBC_SHA | 1+ | 1--8, 11+ |
| EDH-DSS-DES-CBC-SHA | SSL_DHE_DSS_WITH_DES_CBC_SHA | 1--22 | 1--19 |
| EDH-DSS-DES-CBC3-SHA | SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA | 1--22 | 1--19 |
| EDH-RSA-DES-CBC-SHA | SSL_DHE_RSA_WITH_DES_CBC_SHA | 1--22 | 1--19 |
| EDH-RSA-DES-CBC3-SHA | SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA | 1--22 | 1--19 |
| EXP-DES-CBC-SHA | SSL_RSA_EXPORT_WITH_DES40_CBC_SHA | 1--22 | 1--19 |
| EXP-EDH-DSS-DES-CBC-SHA | SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA | 1--22 | 1--19 |
| EXP-EDH-RSA-DES-CBC-SHA | SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA | 1--22 | 1--19 |
| EXP-RC2-CBC-MD5 | SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5 | 1--8 | 1--8 |
| EXP-RC4-MD5 | SSL_RSA_EXPORT_WITH_RC4_40_MD5 | 1--22 | 1--19 |
| RC2-CBC-MD5 | SSL_CK_RC2_128_CBC_WITH_MD5 | 1--8 | 1--8 |
| RC4-MD5 | SSL_RSA_WITH_RC4_128_MD5 | 1--25 | 1--19 |
| RC4-SHA | SSL_RSA_WITH_RC4_128_SHA | 1--25 | 1--23 |

<br />

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLServerSocket.html`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocketFactory.html`

### Protected Constructor Summary

|---|---|
|   | [SSLSocket](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#SSLSocket())() Used only by subclasses. |
|   | [SSLSocket](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#SSLSocket(java.lang.String,%20int))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) host, int port) Used only by subclasses. |
|   | [SSLSocket](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#SSLSocket(java.net.InetAddress,%20int))([InetAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/InetAddress.html) address, int port) Used only by subclasses. |
|   | [SSLSocket](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#SSLSocket(java.lang.String,%20int,%20java.net.InetAddress,%20int))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) host, int port, [InetAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/InetAddress.html) clientAddress, int clientPort) Used only by subclasses. |
|   | [SSLSocket](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#SSLSocket(java.net.InetAddress,%20int,%20java.net.InetAddress,%20int))([InetAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/InetAddress.html) address, int port, [InetAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/InetAddress.html) clientAddress, int clientPort) Used only by subclasses. |

### Public Method Summary

|---|---|
| abstract void | [addHandshakeCompletedListener](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#addHandshakeCompletedListener(javax.net.ssl.HandshakeCompletedListener))([HandshakeCompletedListener](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/HandshakeCompletedListener.html) listener) Registers an event listener to receive notifications that an SSL handshake has completed on this connection. |
| abstract boolean | [getEnableSessionCreation](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#getEnableSessionCreation())() Returns true if new SSL sessions may be established by this socket. |
| abstract [String\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [getEnabledCipherSuites](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#getEnabledCipherSuites())() Returns the names of the SSL cipher suites which are currently enabled for use on this connection. |
| abstract [String\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [getEnabledProtocols](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#getEnabledProtocols())() Returns the names of the protocol versions which are currently enabled for use on this connection. |
| [SSLSession](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSession.html) | [getHandshakeSession](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#getHandshakeSession())() Returns the `SSLSession` being constructed during a SSL/TLS handshake. |
| abstract boolean | [getNeedClientAuth](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#getNeedClientAuth())() Returns true if the socket will *require* client authentication. |
| [SSLParameters](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLParameters.html) | [getSSLParameters](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#getSSLParameters())() Returns the SSLParameters in effect for this SSLSocket. |
| abstract [SSLSession](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSession.html) | [getSession](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#getSession())() Returns the SSL Session in use by this connection. |
| abstract [String\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [getSupportedCipherSuites](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#getSupportedCipherSuites())() Returns the names of the cipher suites which could be enabled for use on this connection. |
| abstract [String\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [getSupportedProtocols](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#getSupportedProtocols())() Returns the names of the protocols which could be enabled for use on an SSL connection. |
| abstract boolean | [getUseClientMode](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#getUseClientMode())() Returns true if the socket is set to use client mode when handshaking. |
| abstract boolean | [getWantClientAuth](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#getWantClientAuth())() Returns true if the socket will *request* client authentication. |
| abstract void | [removeHandshakeCompletedListener](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#removeHandshakeCompletedListener(javax.net.ssl.HandshakeCompletedListener))([HandshakeCompletedListener](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/HandshakeCompletedListener.html) listener) Removes a previously registered handshake completion listener. |
| abstract void | [setEnableSessionCreation](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#setEnableSessionCreation(boolean))(boolean flag) Controls whether new SSL sessions may be established by this socket. |
| abstract void | [setEnabledCipherSuites](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#setEnabledCipherSuites(java.lang.String[]))([String\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) suites) Sets the cipher suites enabled for use on this connection. |
| abstract void | [setEnabledProtocols](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#setEnabledProtocols(java.lang.String[]))([String\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) protocols) Sets the protocol versions enabled for use on this connection. |
| abstract void | [setNeedClientAuth](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#setNeedClientAuth(boolean))(boolean need) Configures the socket to *require* client authentication. |
| void | [setSSLParameters](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#setSSLParameters(javax.net.ssl.SSLParameters))([SSLParameters](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLParameters.html) params) Applies SSLParameters to this socket. |
| abstract void | [setUseClientMode](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#setUseClientMode(boolean))(boolean mode) Configures the socket to use client (or server) mode when handshaking. |
| abstract void | [setWantClientAuth](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#setWantClientAuth(boolean))(boolean want) Configures the socket to *request* client authentication. |
| abstract void | [startHandshake](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#startHandshake())() Starts an SSL handshake on this connection. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#toString())() Converts this socket to a `String`. |

### Inherited Method Summary

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

|---|---|
| void | [bind](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#bind(java.net.SocketAddress))([SocketAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketAddress.html) bindpoint) Binds the socket to a local address. |
| synchronized void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#close())() Closes this socket. |
| void | [connect](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#connect(java.net.SocketAddress,%20int))([SocketAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketAddress.html) endpoint, int timeout) Connects this socket to the server with a specified timeout value. |
| void | [connect](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#connect(java.net.SocketAddress))([SocketAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketAddress.html) endpoint) Connects this socket to the server. |
| [SocketChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SocketChannel.html) | [getChannel](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#getChannel())() Returns the unique `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/channels/SocketChannel.html` object associated with this socket, if any. |
| [InetAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/InetAddress.html) | [getInetAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#getInetAddress())() Returns the address to which the socket is connected. |
| [InputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/InputStream.html) | [getInputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#getInputStream())() Returns an input stream for this socket. |
| boolean | [getKeepAlive](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#getKeepAlive())() Tests if `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketOptions.html#SO_KEEPALIVE` is enabled. |
| [InetAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/InetAddress.html) | [getLocalAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#getLocalAddress())() Gets the local address to which the socket is bound. |
| int | [getLocalPort](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#getLocalPort())() Returns the local port number to which this socket is bound. |
| [SocketAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketAddress.html) | [getLocalSocketAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#getLocalSocketAddress())() Returns the address of the endpoint this socket is bound to. |
| boolean | [getOOBInline](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#getOOBInline())() Tests if `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketOptions.html#SO_OOBINLINE` is enabled. |
| [OutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/OutputStream.html) | [getOutputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#getOutputStream())() Returns an output stream for this socket. |
| int | [getPort](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#getPort())() Returns the remote port number to which this socket is connected. |
| synchronized int | [getReceiveBufferSize](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#getReceiveBufferSize())() Gets the value of the `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketOptions.html#SO_RCVBUF` option for this `Socket`, that is the buffer size used by the platform for input on this `Socket`. |
| [SocketAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketAddress.html) | [getRemoteSocketAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#getRemoteSocketAddress())() Returns the address of the endpoint this socket is connected to, or `null` if it is unconnected. |
| boolean | [getReuseAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#getReuseAddress())() Tests if `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketOptions.html#SO_REUSEADDR` is enabled. |
| synchronized int | [getSendBufferSize](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#getSendBufferSize())() Get value of the `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketOptions.html#SO_SNDBUF` option for this `Socket`, that is the buffer size used by the platform for output on this `Socket`. |
| int | [getSoLinger](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#getSoLinger())() Returns setting for `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketOptions.html#SO_LINGER`. |
| synchronized int | [getSoTimeout](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#getSoTimeout())() Returns setting for `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketOptions.html#SO_TIMEOUT`. |
| boolean | [getTcpNoDelay](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#getTcpNoDelay())() Tests if `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketOptions.html#TCP_NODELAY` is enabled. |
| int | [getTrafficClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#getTrafficClass())() Gets traffic class or type-of-service in the IP header for packets sent from this Socket As the underlying network implementation may ignore the traffic class or type-of-service set using `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#setTrafficClass(int)` this method may return a different value than was previously set using the `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#setTrafficClass(int)` method on this Socket. |
| boolean | [isBound](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#isBound())() Returns the binding state of the socket. |
| boolean | [isClosed](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#isClosed())() Returns the closed state of the socket. |
| boolean | [isConnected](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#isConnected())() Returns the connection state of the socket. |
| boolean | [isInputShutdown](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#isInputShutdown())() Returns whether the read-half of the socket connection is closed. |
| boolean | [isOutputShutdown](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#isOutputShutdown())() Returns whether the write-half of the socket connection is closed. |
| void | [sendUrgentData](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#sendUrgentData(int))(int data) Send one byte of urgent data on the socket. |
| void | [setKeepAlive](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#setKeepAlive(boolean))(boolean on) Enable/disable `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketOptions.html#SO_KEEPALIVE`. |
| void | [setOOBInline](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#setOOBInline(boolean))(boolean on) Enable/disable `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketOptions.html#SO_OOBINLINE` (receipt of TCP urgent data) By default, this option is disabled and TCP urgent data received on a socket is silently discarded. |
| void | [setPerformancePreferences](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#setPerformancePreferences(int,%20int,%20int))(int connectionTime, int latency, int bandwidth) Sets performance preferences for this socket. |
| synchronized void | [setReceiveBufferSize](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#setReceiveBufferSize(int))(int size) Sets the `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketOptions.html#SO_RCVBUF` option to the specified value for this `Socket`. |
| void | [setReuseAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#setReuseAddress(boolean))(boolean on) Enable/disable the `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketOptions.html#SO_REUSEADDR` socket option. |
| synchronized void | [setSendBufferSize](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#setSendBufferSize(int))(int size) Sets the `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketOptions.html#SO_SNDBUF` option to the specified value for this `Socket`. |
| void | [setSoLinger](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#setSoLinger(boolean,%20int))(boolean on, int linger) Enable/disable `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketOptions.html#SO_LINGER` with the specified linger time in seconds. |
| synchronized void | [setSoTimeout](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#setSoTimeout(int))(int timeout) Enable/disable `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketOptions.html#SO_TIMEOUT` with the specified timeout, in milliseconds. |
| synchronized static void | [setSocketImplFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#setSocketImplFactory(java.net.SocketImplFactory))([SocketImplFactory](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketImplFactory.html) fac) Sets the client socket implementation factory for the application. |
| void | [setTcpNoDelay](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#setTcpNoDelay(boolean))(boolean on) Enable/disable `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/SocketOptions.html#TCP_NODELAY` (disable/enable Nagle's algorithm). |
| void | [setTrafficClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#setTrafficClass(int))(int tc) Sets traffic class or type-of-service octet in the IP header for packets sent from this Socket. |
| void | [shutdownInput](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#shutdownInput())() Places the input stream for this socket at "end of stream". |
| void | [shutdownOutput](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#shutdownOutput())() Disables the output stream for this socket. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/Socket.html#toString())() Converts this socket to a `String`. |

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. |

From interface [java.io.Closeable](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Closeable.html)

|---|---|
| abstract void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Closeable.html#close())() Closes this stream and releases any system resources associated with it. |

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

|---|---|
| abstract void | [close](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/AutoCloseable.html#close())() Closes this resource, relinquishing any underlying resources. |

## Protected Constructors

#### protected
**SSLSocket**
()

Used only by subclasses.
Constructs an uninitialized, unconnected TCP socket.

#### protected
**SSLSocket**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) host, int port)

Used only by subclasses.
Constructs a TCP connection to a named host at a specified port.
This acts as the SSL client.


If there is a security manager, its `checkConnect`
method is called with the host address and `port`
as its arguments. This could result in a SecurityException.

##### Parameters

| host | name of the host with which to connect, or `null` for the loopback address. |
| port | number of the server's port |
|---|---|

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | if an I/O error occurs when creating the socket |
| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and its `checkConnect` method doesn't allow the operation. |
| [UnknownHostException](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/UnknownHostException.html) | if the host is not known |
| [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#checkConnect(java.lang.String,%20int)`

#### protected
**SSLSocket**
([InetAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/InetAddress.html) address, int port)

Used only by subclasses.
Constructs a TCP connection to a server at a specified address
and port. This acts as the SSL client.


If there is a security manager, its `checkConnect`
method is called with the host address and `port`
as its arguments. This could result in a SecurityException.

##### Parameters

| address | the server's host |
| port | its port |
|---|---|

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | if an I/O error occurs when creating the socket |
| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and its `checkConnect` 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. |
| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if `address` is null. |
|---|---|

##### See Also

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

#### protected
**SSLSocket**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) host, int port, [InetAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/InetAddress.html) clientAddress, int clientPort)

Used only by subclasses.
Constructs an SSL connection to a named host at a specified port,
binding the client side of the connection a given address and port.
This acts as the SSL client.


If there is a security manager, its `checkConnect`
method is called with the host address and `port`
as its arguments. This could result in a SecurityException.

##### Parameters

| host | name of the host with which to connect, or `null` for the loopback address. |
| port | number of the server's port |
| clientAddress | the client's address the socket is bound to, or `null` for the `anyLocal` address. |
| clientPort | the client's port the socket is bound to, or `zero` for a system selected free port. |
|---|---|

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | if an I/O error occurs when creating the socket |
| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and its `checkConnect` method doesn't allow the operation. |
| [UnknownHostException](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/UnknownHostException.html) | if the host is not known |
| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if the port parameter or clientPort 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#checkConnect(java.lang.String,%20int)`

#### protected
**SSLSocket**
([InetAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/InetAddress.html) address, int port, [InetAddress](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/InetAddress.html) clientAddress, int clientPort)

Used only by subclasses.
Constructs an SSL connection to a server at a specified address
and TCP port, binding the client side of the connection a given
address and port. This acts as the SSL client.


If there is a security manager, its `checkConnect`
method is called with the host address and `port`
as its arguments. This could result in a SecurityException.

##### Parameters

| address | the server's host |
| port | its port |
| clientAddress | the client's address the socket is bound to, or `null` for the `anyLocal` address. |
| clientPort | the client's port the socket is bound to, or `zero` for a system selected free port. |
|---|---|

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | if an I/O error occurs when creating the socket |
| [SecurityException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/SecurityException.html) | if a security manager exists and its `checkConnect` method doesn't allow the operation. |
| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if the port parameter or clientPort parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive. |
| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if `address` is null. |
|---|---|

##### See Also

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

## Public Methods

#### public abstract void
**addHandshakeCompletedListener**
([HandshakeCompletedListener](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/HandshakeCompletedListener.html) listener)

Registers an event listener to receive notifications that an
SSL handshake has completed on this connection.

##### Parameters

| listener | the HandShake Completed event listener |
|---|---|

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if the argument is null. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#startHandshake()`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#removeHandshakeCompletedListener(javax.net.ssl.HandshakeCompletedListener)`

#### public abstract boolean
**getEnableSessionCreation**
()

Returns true if new SSL sessions may be established by this socket.

##### Returns

- true indicates that sessions may be created; this is the default. false indicates that an existing session must be resumed

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#setEnableSessionCreation(boolean)`

#### public abstract [String\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**getEnabledCipherSuites**
()

Returns the names of the SSL cipher suites which are currently
enabled for use on this connection. When an SSLSocket is first
created, all enabled cipher suites support a minimum quality of
service. Thus, in some environments this value might be empty.


Even if a suite has been enabled, it might never be used. (For
example, the peer does not support it, the requisite certificates
(and private keys) for the suite are not available, or an
anonymous suite is enabled but authentication is required.

##### Returns

- an array of cipher suite names

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#getSupportedCipherSuites()`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#setEnabledCipherSuites(java.lang.String[])`

#### public abstract [String\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**getEnabledProtocols**
()

Returns the names of the protocol versions which are currently
enabled for use on this connection.

##### Returns

- an array of protocols

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#setEnabledProtocols(java.lang.String[])`

#### public [SSLSession](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSession.html)
**getHandshakeSession**
()

Returns the `SSLSession` being constructed during a SSL/TLS
handshake.


TLS protocols may negotiate parameters that are needed when using
an instance of this class, but before the `SSLSession` has
been completely initialized and made available via `getSession`.
For example, the list of valid signature algorithms may restrict
the type of certificates that can used during TrustManager
decisions, or the maximum TLS fragment packet sizes can be
resized to better support the network environment.


This method provides early access to the `SSLSession` being
constructed. Depending on how far the handshake has progressed,
some data may not yet be available for use. For example, if a
remote server will be sending a Certificate chain, but that chain
has yet not been processed, the `getPeerCertificates`
method of `SSLSession` will throw a
SSLPeerUnverifiedException. Once that chain has been processed,
`getPeerCertificates` will return the proper value.


Unlike `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#getSession()`, this method does not initiate the
initial handshake and does not block until handshaking is
complete.

##### Returns

- null if this instance is not currently handshaking, or if the current handshake has not progressed far enough to create a basic SSLSession. Otherwise, this method returns the `SSLSession` currently being negotiated.

##### Throws

| [UnsupportedOperationException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/UnsupportedOperationException.html) | if the underlying provider does not implement the operation. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLEngine.html`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSession.html`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/ExtendedSSLSession.html`
- `https://developers.google.com/j2objc/javadoc/jre/`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/X509ExtendedTrustManager.html`

#### public abstract boolean
**getNeedClientAuth**
()

Returns true if the socket will *require* client authentication.
This option is only useful to sockets in the server mode.

##### Returns

- true if client authentication is required, or false if no client authentication is desired.

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#setNeedClientAuth(boolean)`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#setWantClientAuth(boolean)`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#getWantClientAuth()`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#setUseClientMode(boolean)`

#### public [SSLParameters](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLParameters.html)
**getSSLParameters**
()

Returns the SSLParameters in effect for this SSLSocket.
The ciphersuites and protocols of the returned SSLParameters
are always non-null.

##### Returns

- the SSLParameters in effect for this SSLSocket.

#### public abstract [SSLSession](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSession.html)
**getSession**
()

Returns the SSL Session in use by this connection. These can
be long lived, and frequently correspond to an entire login session
for some user. The session specifies a particular cipher suite
which is being actively used by all connections in that session,
as well as the identities of the session's client and server.


This method will initiate the initial handshake if
necessary and then block until the handshake has been
established.


If an error occurs during the initial handshake, this method
returns an invalid session object which reports an invalid
cipher suite of "SSL_NULL_WITH_NULL_NULL".

##### Returns

- the `SSLSession`

#### public abstract [String\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**getSupportedCipherSuites**
()

Returns the names of the cipher suites which could be enabled for use
on this 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 might be useful in specialized applications.

##### Returns

- an array of cipher suite names

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#getEnabledCipherSuites()`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#setEnabledCipherSuites(java.lang.String[])`

#### public abstract [String\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**getSupportedProtocols**
()

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

##### Returns

- an array of protocols supported

#### public abstract boolean
**getUseClientMode**
()

Returns true if the socket is set to use client mode when
handshaking.

##### Returns

- true if the socket should do handshaking in "client" mode

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#setUseClientMode(boolean)`

#### public abstract boolean
**getWantClientAuth**
()

Returns true if the socket will *request* client authentication.
This option is only useful for sockets in the server mode.

##### Returns

- true if client authentication is requested, or false if no client authentication is desired.

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#setNeedClientAuth(boolean)`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#getNeedClientAuth()`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#setWantClientAuth(boolean)`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#setUseClientMode(boolean)`

#### public abstract void
**removeHandshakeCompletedListener**
([HandshakeCompletedListener](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/HandshakeCompletedListener.html) listener)

Removes a previously registered handshake completion listener.

##### Parameters

| listener | the HandShake Completed event listener |
|---|---|

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if the listener is not registered, or the argument is null. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#addHandshakeCompletedListener(javax.net.ssl.HandshakeCompletedListener)`

#### public abstract void
**setEnableSessionCreation**
(boolean flag)

Controls whether new SSL sessions may be established by this socket.
If session creations are not allowed, and there are no
existing sessions to resume, there will be no successful
handshaking.

##### Parameters

| flag | true indicates that sessions may be created; this is the default. false indicates that an existing session must be resumed |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#getEnableSessionCreation()`

#### public abstract void
**setEnabledCipherSuites**
([String\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) suites)

Sets the cipher suites enabled for use on this connection.


Each cipher suite in the `suites` parameter must have
been listed by getSupportedCipherSuites(), or the method will
fail. Following a successful call to this method, only suites
listed in the `suites` parameter are enabled for use.


See `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#getEnabledCipherSuites()` for more information
on why a specific ciphersuite may never be used on a connection.

##### Parameters

| suites | Names of all the cipher suites to enable |
|---|---|

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | when one or more of the ciphers named by the parameter is not supported, or when the parameter is null. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#getSupportedCipherSuites()`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#getEnabledCipherSuites()`

#### public abstract void
**setEnabledProtocols**
([String\[\]](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) protocols)

Sets the protocol versions enabled for use on this connection.


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.

##### Parameters

| protocols | Names of all the protocols to enable. |
|---|---|

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | when one or more of the protocols named by the parameter is not supported or when the protocols parameter is null. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#getEnabledProtocols()`

#### public abstract void
**setNeedClientAuth**
(boolean need)

Configures the socket to *require* client authentication. This
option is only useful for sockets in the server mode.


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

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


Unlike `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#setWantClientAuth(boolean)`, if this 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://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#setWantClientAuth(boolean)`.

##### Parameters

| need | set to true if client authentication is required, or false if no client authentication is desired. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#getNeedClientAuth()`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#setWantClientAuth(boolean)`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#getWantClientAuth()`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#setUseClientMode(boolean)`

#### public void
**setSSLParameters**
([SSLParameters](https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLParameters.html) params)

Applies SSLParameters to this socket.

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 />

##### Parameters

| params | the parameters |
|---|---|

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if the setEnabledCipherSuites() or the setEnabledProtocols() call fails |
|---|---|

#### public abstract void
**setUseClientMode**
(boolean mode)

Configures the socket to use client (or server) mode when
handshaking.


This method must be called before any handshaking occurs.
Once handshaking has begun, the mode can not be reset for the
life of this socket.


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

##### Parameters

| mode | true if the socket should start its handshaking in "client" mode |
|---|---|

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if a mode change is attempted after the initial handshake has begun. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#getUseClientMode()`

#### public abstract void
**setWantClientAuth**
(boolean want)

Configures the socket to *request* client authentication.
This option is only useful for sockets in the server mode.


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

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


Unlike `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#setNeedClientAuth(boolean)`, if this 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://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#setNeedClientAuth(boolean)`.

##### Parameters

| want | set to true if client authentication is requested, or false if no client authentication is desired. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#getWantClientAuth()`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#setNeedClientAuth(boolean)`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#getNeedClientAuth()`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#setUseClientMode(boolean)`

#### public abstract void
**startHandshake**
()

Starts an SSL handshake on this connection. Common reasons include
a need to use new encryption keys, to change cipher suites, or to
initiate a new session. To force complete reauthentication, the
current session could be invalidated before starting this handshake.

If data has already been sent on the connection, it continues
to flow during this handshake. When the handshake completes, this
will be signaled with an event.

This method is synchronous for the initial handshake on a connection
and returns when the negotiated handshake is complete. Some
protocols may not support multiple handshakes on an existing socket
and may throw an IOException.

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | on a network level error |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLSocket.html#addHandshakeCompletedListener(javax.net.ssl.HandshakeCompletedListener)`

#### public [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**toString**
()

Converts this socket to a `String`.

##### Returns

- a string representation of this socket.