Top Description Methods
org.apache.hc.client5.http.socket

public Interface ConnectionSocketFactory

Known Direct Subinterfaces
org.apache.hc.client5.http.socket.LayeredConnectionSocketFactory
Known Direct Implementers
org.apache.hc.client5.http.socket.PlainConnectionSocketFactory
Annotations
@Contract
threading:STATELESS
Imports
java.io.IOException, java.net.InetSocketAddress, .Proxy, .Socket, org.apache.hc.core5.annotation.Contract, .Internal, .ThreadingBehavior, org.apache.hc.core5.http.HttpHost, org.apache.hc.core5.http.protocol.HttpContext, org.apache.hc.core5.util.TimeValue, .Timeout

A factory for creating and connecting connection sockets.
Since
4.3

Method Summary

Modifier and TypeMethod and Description
public Socket

Returns:

the connected socket. The returned object may be different from the sock argument if this factory supports a layered protocol.
connectSocket
(TimeValue
connect timeout.
connectTimeout
,
Socket
the socket to connect, as obtained from createSocket(HttpContext). null indicates that a new socket should be created and connected.
socket
,
HttpHost
target host as specified by the caller (end user).
host
,
InetSocketAddress
the resolved remote address to connect to.
remoteAddress
,
InetSocketAddress
the local address to bind the socket to, or null for any.
localAddress
,
HttpContext
the actual HTTP context.
context
)

Connects the socket to the target host with the given resolved remote address.

public default Socket

Returns:

the connected socket. The returned object may be different from the sock argument if this factory supports a layered protocol.
connectSocket
(Socket
the socket to connect, as obtained from createSocket(HttpContext). null indicates that a new socket should be created and connected.
socket
,
HttpHost
target host as specified by the caller (end user).
host
,
InetSocketAddress
the resolved remote address to connect to.
remoteAddress
,
InetSocketAddress
the local address to bind the socket to, or null for any.
localAddress
,
Timeout
connect timeout.
connectTimeout
,
Object
connect request attachment.
attachment
,
HttpContext
the actual HTTP context.
context
)

Connects the socket to the target host with the given resolved remote address.

public Socket
createSocket(HttpContext context)

Creates new, unconnected socket.

public default Socket
createSocket(Proxy proxy, HttpContext context)

Creates new, unconnected socket via a proxy (generally SOCKS is expected).

Method Detail

connectSocketback to summary
public Socket connectSocket(TimeValue connectTimeout, Socket socket, HttpHost host, InetSocketAddress remoteAddress, InetSocketAddress localAddress, HttpContext context) throws IOException

Connects the socket to the target host with the given resolved remote address.

Parameters
connectTimeout:TimeValue

connect timeout.

socket:Socket

the socket to connect, as obtained from createSocket(HttpContext). null indicates that a new socket should be created and connected.

host:HttpHost

target host as specified by the caller (end user).

remoteAddress:InetSocketAddress

the resolved remote address to connect to.

localAddress:InetSocketAddress

the local address to bind the socket to, or null for any.

context:HttpContext

the actual HTTP context.

Returns:Socket

the connected socket. The returned object may be different from the sock argument if this factory supports a layered protocol.

Exceptions
IOException:
if an I/O error occurs
connectSocketback to summary
public default Socket connectSocket(Socket socket, HttpHost host, InetSocketAddress remoteAddress, InetSocketAddress localAddress, Timeout connectTimeout, Object attachment, HttpContext context) throws IOException

Connects the socket to the target host with the given resolved remote address.

Parameters
socket:Socket

the socket to connect, as obtained from createSocket(HttpContext). null indicates that a new socket should be created and connected.

host:HttpHost

target host as specified by the caller (end user).

remoteAddress:InetSocketAddress

the resolved remote address to connect to.

localAddress:InetSocketAddress

the local address to bind the socket to, or null for any.

connectTimeout:Timeout

connect timeout.

attachment:Object

connect request attachment.

context:HttpContext

the actual HTTP context.

Returns:Socket

the connected socket. The returned object may be different from the sock argument if this factory supports a layered protocol.

Exceptions
IOException:
if an I/O error occurs
Since
5.2
createSocketback to summary
public Socket createSocket(HttpContext context) throws IOException

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

createSocketback to summary
public default Socket createSocket(Proxy proxy, HttpContext context) throws IOException

Creates new, unconnected socket via a proxy (generally SOCKS is expected). The socket should subsequently be passed to connectSocket method.

Annotations
@Internal
Since
5.2