org.apache.http.conn.socket

## Interface ConnectionSocketFactory

- All Known Subinterfaces:
    LayeredConnectionSocketFactory
  All Known Implementing Classes:
    PlainConnectionSocketFactory, SSLConnectionSocketFactory, SSLSocketFactory

      public interface ConnectionSocketFactory

  A factory for creating and connecting connection sockets.
  Since:
    4.3

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Socket` | `connectSocket(int connectTimeout, Socket sock, org.apache.http.HttpHost host, InetSocketAddress remoteAddress, InetSocketAddress localAddress, org.apache.http.protocol.HttpContext context)` Connects the socket to the target host with the given resolved remote address.
    `Socket` | `createSocket(org.apache.http.protocol.HttpContext context)` Creates new, unconnected socket.

- - ### Method Detail

    - #### createSocket

          Socket createSocket(org.apache.http.protocol.HttpContext context)
                              throws IOException

      Creates new, unconnected socket. The socket should subsequently be passed to `connectSocket` method.
      Returns:
        a new socket
      Throws:
        `IOException` - if an I/O error occurs while creating the socket

    - #### connectSocket

          Socket connectSocket(int connectTimeout,
                             Socket sock,
                             org.apache.http.HttpHost host,
                             InetSocketAddress remoteAddress,
                             InetSocketAddress localAddress,
                             org.apache.http.protocol.HttpContext context)
                               throws IOException

      Connects the socket to the target host with the given resolved remote address.
      Parameters:
        `connectTimeout` - connect timeout.
        `sock` - the socket to connect, as obtained from `createSocket(HttpContext)`. `null` indicates that a new socket should be created and connected.
        `host` - target host as specified by the caller (end user).
        `remoteAddress` - the resolved remote address to connect to.
        `localAddress` - the local address to bind the socket to, or `null` for any.
        `context` - the actual HTTP context.
      Returns:
        the connected socket. The returned object may be different from the `sock` argument if this factory supports a layered protocol.
      Throws:
        `IOException` - if an I/O error occurs

Copyright © 1999–2022 The Apache Software Foundation. All rights reserved.