public class

PlainSocketFactory

extends Object
implements SchemeSocketFactory SocketFactory
java.lang.Object
   ↳ org.apache.http.conn.scheme.PlainSocketFactory

Class Overview

The default class for creating plain (unencrypted) sockets.

The following parameters can be used to customize the behavior of this class:

Summary

Public Constructors
PlainSocketFactory(HostNameResolver nameResolver)
PlainSocketFactory()
Public Methods
Socket connectSocket(Socket socket, InetSocketAddress remoteAddress, InetSocketAddress localAddress, HttpParams params)
Connects a socket to the target host with the given remote address.
Socket connectSocket(Socket socket, String host, int port, InetAddress localAddress, int localPort, HttpParams params)
Socket createSocket()
Creates a new, unconnected socket.
Socket createSocket(HttpParams params)
Creates a new, unconnected socket.
static PlainSocketFactory getSocketFactory()
Gets the default factory.
final boolean isSecure(Socket sock)
Checks whether a socket connection is secure.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.apache.http.conn.scheme.SchemeSocketFactory
From interface org.apache.http.conn.scheme.SocketFactory

Public Constructors

public PlainSocketFactory (HostNameResolver nameResolver)

Also: HttpClient

public PlainSocketFactory ()

Also: HttpClient

Public Methods

public Socket connectSocket (Socket socket, InetSocketAddress remoteAddress, InetSocketAddress localAddress, HttpParams params)

Also: HttpClient

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

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.

public Socket connectSocket (Socket socket, String host, int port, InetAddress localAddress, int localPort, HttpParams params)

Also: HttpClient

This method is deprecated.
Use connectSocket(Socket, InetSocketAddress, InetSocketAddress, HttpParams)

Connects a socket to the given host.

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.

public Socket createSocket ()

Also: HttpClient

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

Returns
  • a new socket

public Socket createSocket (HttpParams params)

Also: HttpClient

Creates a new, unconnected socket. The socket should subsequently be passed to connectSocket(Socket, InetSocketAddress, InetSocketAddress, HttpParams).

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

public static PlainSocketFactory getSocketFactory ()

Also: HttpClient

Gets the default factory.

Returns
  • the default factory

public final boolean isSecure (Socket sock)

Also: HttpClient

Checks whether a socket connection is secure. This factory creates plain socket connections which are not considered secure.

Parameters
sock the connected socket
Returns
  • false
Throws
IllegalArgumentException if the argument is invalid