Stay organized with collections
Save and categorize content based on your preferences.
LayeredSocketFactory
interface LayeredSocketFactory : SocketFactory
A SocketFactory
for layered sockets (SSL/TLS). See there for things to consider when implementing a socket factory.
Summary
Public methods |
abstract Socket! |
Returns a socket connected to the given host that is layered over an existing socket.
|
Inherited functions |
From class SocketFactory
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
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 |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# LayeredSocketFactory\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nDeprecated in [API level 22](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nLayeredSocketFactory\n====================\n\n```\ninterface LayeredSocketFactory : SocketFactory\n```\n\n|-------------------------------------------------------|\n| [org.apache.http.conn.scheme.LayeredSocketFactory](#) |\n\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known Direct Subclasses [SSLSocketFactory](../ssl/SSLSocketFactory.html#) |---------------------------------------------------|----------------------------------------------------------------| | [SSLSocketFactory](../ssl/SSLSocketFactory.html#) | Layered socket factory for TLS/SSL connections, based on JSSE. | |\n\n*** ** * ** ***\n\n| **This interface was deprecated in API level 22.**\n|\n| Please use java.net.URL#openConnection instead. Please visit [this webpage](http://android-developers.blogspot.com/2011/09/androids-http-clients.html) for further details.\n\nA [SocketFactory](/reference/kotlin/org/apache/http/conn/scheme/SocketFactory) for layered sockets (SSL/TLS). See there for things to consider when implementing a socket factory.\n\nSummary\n-------\n\n| Public methods ||\n|----------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Socket](../../../../../java/net/Socket.html#)! | [createSocket](#createSocket(java.net.Socket,%20kotlin.String,%20kotlin.Int,%20kotlin.Boolean))`(`socket:` `[Socket](../../../../../java/net/Socket.html#)!`, `host:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `port:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `autoClose:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Returns a socket connected to the given host that is layered over an existing socket. |\n\n| Inherited functions ||\n|---|---|\n| From class [SocketFactory](/reference/kotlin/org/apache/http/conn/scheme/SocketFactory) |------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Socket](../../../../../java/net/Socket.html#)! | [connectSocket](/reference/kotlin/org/apache/http/conn/scheme/SocketFactory#connectSocket(java.net.Socket,%20kotlin.String,%20kotlin.Int,%20java.net.InetAddress,%20kotlin.Int,%20org.apache.http.params.HttpParams))`(`sock:` `[Socket](../../../../../java/net/Socket.html#)!`, `host:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `port:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `localAddress:` `[InetAddress](../../../../../java/net/InetAddress.html#)!`, `localPort:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `params:` `[HttpParams](../../params/HttpParams.html#)!`)` Connects a socket to the given host. \u003cbr /\u003e | | [Socket](../../../../../java/net/Socket.html#)! | [createSocket](/reference/kotlin/org/apache/http/conn/scheme/SocketFactory#createSocket())`()` Creates a new, unconnected socket. The socket should subsequently be passed to [connectSocket](/reference/kotlin/org/apache/http/conn/scheme/SocketFactory#connectSocket(java.net.Socket,%20kotlin.String,%20kotlin.Int,%20java.net.InetAddress,%20kotlin.Int,%20org.apache.http.params.HttpParams)). \u003cbr /\u003e | | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [isSecure](/reference/kotlin/org/apache/http/conn/scheme/SocketFactory#isSecure(java.net.Socket))`(`sock:` `[Socket](../../../../../java/net/Socket.html#)!`)` Checks whether a socket provides a secure connection. The socket must be [connected](/reference/kotlin/org/apache/http/conn/scheme/SocketFactory#connectSocket(java.net.Socket,%20kotlin.String,%20kotlin.Int,%20java.net.InetAddress,%20kotlin.Int,%20org.apache.http.params.HttpParams)) 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. \u003cbr /\u003e | ||\n\nPublic methods\n--------------\n\n### createSocket\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun createSocket(\n socket: Socket!, \n host: String!, \n port: Int, \n autoClose: Boolean\n): Socket!\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nReturns a socket connected to the given host that is layered over an existing socket. Used primarily for creating secure sockets through proxies.\n\n| Parameters ||\n|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `socket` | [Socket](../../../../../java/net/Socket.html#)!: the existing socket |\n| `host` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!: the host name/IP |\n| `port` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the port on the host |\n| `autoClose` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): a flag for closing the underling socket when the created socket is closed |\n\n| Return ||\n|-------------------------------------------------|---------------------|\n| [Socket](../../../../../java/net/Socket.html#)! | Socket a new socket |\n\n| Exceptions ||\n|---------------------------------|----------------------------------------------------|\n| `java.io.IOException` | if an I/O error occurs while creating the socket |\n| `java.net.UnknownHostException` | if the IP address of the host cannot be determined |"]]