Added in API level 1
Deprecated in API level 22

LayeredSocketFactory

interface LayeredSocketFactory : SocketFactory
SSLSocketFactory

Layered socket factory for TLS/SSL connections, based on JSSE.


A SocketFactory for layered sockets (SSL/TLS). See there for things to consider when implementing a socket factory.

Summary

Public methods
abstract Socket!
createSocket(socket: Socket!, host: String!, port: Int, autoClose: Boolean)

Returns a socket connected to the given host that is layered over an existing socket.

Inherited functions
Socket! connectSocket(sock: Socket!, host: String!, port: Int, localAddress: InetAddress!, localPort: Int, params: HttpParams!)

Connects a socket to the given host.

Socket! createSocket()

Creates a new, unconnected socket. The socket should subsequently be passed to connectSocket.

Boolean isSecure(sock: Socket!)

Checks whether a socket provides a secure connection. The socket must be connected by this factory. The factory will not perform I/O operations in this method.
As a rule of thumb, plain sockets are not secure and TLS/SSL sockets are secure. However, there may be application specific deviations. For example, a plain socket to a host in the same intranet ("trusted zone") could be considered secure. On the other hand, a TLS/SSL socket could be considered insecure based on the cypher suite chosen for the connection.

Public methods

createSocket

Added in API level 1
abstract fun createSocket(
    socket: Socket!,
    host: String!,
    port: Int,
    autoClose: Boolean
): Socket!

Deprecated: Deprecated in Java.

Returns a socket connected to the given host that is layered over an existing socket. Used primarily for creating secure sockets through proxies.

Parameters
socket Socket!: the existing socket
host String!: the host name/IP
port Int: the port on the host
autoClose Boolean: a flag for closing the underling socket when the created socket is closed
Return
Socket! Socket a new socket
Exceptions
java.io.IOException if an I/O error occurs while creating the socket
java.net.UnknownHostException if the IP address of the host cannot be determined