org.apache.http.conn.scheme

## Class PlainSocketFactory

- java.lang.Object
- - org.apache.http.conn.scheme.PlainSocketFactory

- All Implemented Interfaces:
    SchemeSocketFactory, SocketFactory

  Deprecated.
  (4.3) use `PlainConnectionSocketFactory`

      @Contract(threading=IMMUTABLE)
      @Deprecated
      public class PlainSocketFactory
      extends Object
      implements SocketFactory, SchemeSocketFactory

  The default class for creating plain (unencrypted) sockets.
  Since:
    4.0

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PlainSocketFactory()` Deprecated.
    `PlainSocketFactory(HostNameResolver nameResolver)` Deprecated. (4.1) use `DnsResolver`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Socket` | `connectSocket(Socket socket, InetSocketAddress remoteAddress, InetSocketAddress localAddress, org.apache.http.params.HttpParams params)` Deprecated. Connects a socket to the target host with the given remote address.
    `Socket` | `connectSocket(Socket socket, String host, int port, InetAddress localAddress, int localPort, org.apache.http.params.HttpParams params)` Deprecated. (4.1) Use `connectSocket(Socket, InetSocketAddress, InetSocketAddress, HttpParams)`
    `Socket` | `createSocket()` Deprecated. Creates a new, unconnected socket.
    `Socket` | `createSocket(org.apache.http.params.HttpParams params)` Deprecated. Creates a new, unconnected socket.
    `static PlainSocketFactory` | `getSocketFactory()` Deprecated. Gets the default factory.
    `boolean` | `isSecure(Socket sock)` Deprecated. Checks whether a socket connection is secure.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PlainSocketFactory

          @Deprecated
          public PlainSocketFactory(HostNameResolver nameResolver)

      Deprecated. (4.1) use `DnsResolver`

    - #### PlainSocketFactory

          public PlainSocketFactory()

      Deprecated.

  - ### Method Detail

    - #### getSocketFactory

          public static PlainSocketFactory getSocketFactory()

      Deprecated.
      Gets the default factory.
      Returns:
        the default factory

    - #### createSocket

          public Socket createSocket(org.apache.http.params.HttpParams params)

      Deprecated.
      Description copied from interface: `SchemeSocketFactory`
      Creates a new, unconnected socket. The socket should subsequently be passed to `SchemeSocketFactory.connectSocket(Socket, InetSocketAddress, InetSocketAddress, HttpParams)`.
      Specified by:
        `createSocket` in interface `SchemeSocketFactory`
      Parameters:
        `params` - Optional parameters. Parameters passed to this method will have no effect. This method will create a unconnected instance of `Socket` class using default constructor.
      Returns:
        a new socket
      Since:
        4.1

    - #### createSocket

          public Socket createSocket()

      Deprecated.
      Description copied from interface: `SocketFactory`
      Creates a new, unconnected socket. The socket should subsequently be passed to `connectSocket`.
      Specified by:
        `createSocket` in interface `SocketFactory`
      Returns:
        a new socket

    - #### connectSocket

          public Socket connectSocket(Socket socket,
                             InetSocketAddress remoteAddress,
                             InetSocketAddress localAddress,
                             org.apache.http.params.HttpParams params)
                               throws IOException,
                                      ConnectTimeoutException

      Deprecated.
      Description copied from interface: `SchemeSocketFactory`
      Connects a socket to the target host with the given remote address.

      Please note that `HttpInetSocketAddress` class should be used in order to pass the target remote address along with the original `HttpHost` value used to resolve the address. The use of `HttpInetSocketAddress` can also ensure that no reverse DNS lookup will be performed if the target remote address was specified as an IP address.

      Specified by:
        `connectSocket` in interface `SchemeSocketFactory`
      Parameters:
        `socket` - the socket to connect, as obtained from `createSocket`. `null` indicates that a new socket should be created and connected.
        `remoteAddress` - the remote address to connect to.
        `localAddress` - the local address to bind the socket to, or `null` for any
        `params` - additional `parameters` for connecting
      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
        `UnknownHostException` - if the IP address of the target host can not be determined
        `ConnectTimeoutException` - if the socket cannot be connected within the time limit defined in the `params`
      Since:
        4.1
      See Also:
        `HttpInetSocketAddress`

    - #### isSecure

          public final boolean isSecure(Socket sock)

      Deprecated.
      Checks whether a socket connection is secure. This factory creates plain socket connections which are not considered secure.
      Specified by:
        `isSecure` in interface `SchemeSocketFactory`
      Specified by:
        `isSecure` in interface `SocketFactory`
      Parameters:
        `sock` - the connected socket
      Returns:
        `false`

    - #### connectSocket

          @Deprecated
          public Socket connectSocket(Socket socket,
                                        String host,
                                        int port,
                                        InetAddress localAddress,
                                        int localPort,
                                        org.apache.http.params.HttpParams params)
                               throws IOException,
                                      UnknownHostException,
                                      ConnectTimeoutException

      Deprecated. (4.1) Use `connectSocket(Socket, InetSocketAddress, InetSocketAddress, HttpParams)`
      Description copied from interface: `SocketFactory`
      Connects a socket to the given host.
      Specified by:
        `connectSocket` in interface `SocketFactory`
      Parameters:
        `socket` - the socket to connect, as obtained from `createSocket`. `null` indicates that a new socket should be created and connected.
        `host` - the host to connect to
        `port` - the port to connect to on the host
        `localAddress` - the local address to bind the socket to, or `null` for any
        `localPort` - the port on the local machine, 0 or a negative number for any
        `params` - additional `parameters` for connecting
      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
        `UnknownHostException` - if the IP address of the target host can not be determined
        `ConnectTimeoutException` - if the socket cannot be connected within the time limit defined in the `params`

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