Top Description Fields Constructors Methods
org.apache.http.conn.scheme

public Class PlainSocketFactory

extends Object
implements SocketFactory, SchemeSocketFactory
Class Inheritance
All Implemented Interfaces
org.apache.http.conn.scheme.SchemeSocketFactory, org.apache.http.conn.scheme.SocketFactory
Annotations
@Contract
threading:IMMUTABLE
@Deprecated
Imports
java.io.IOException, java.net.InetAddress, .InetSocketAddress, .Socket, .SocketTimeoutException, .UnknownHostException, org.apache.http.annotation.Contract, .ThreadingBehavior, org.apache.http.conn.ConnectTimeoutException, org.apache.http.params.HttpConnectionParams, .HttpParams, org.apache.http.util.Args

Deprecated

(4.3) use org.apache.http.conn.socket.PlainConnectionSocketFactory

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

Field Summary

Modifier and TypeField and Description
private final HostNameResolver
nameResolver

Deprecated as a consequence of HostNameResolver being deprecated.

Constructor Summary

AccessConstructor and Description
public
PlainSocketFactory(final HostNameResolver nameResolver)

Deprecated (4.1) use org.apache.http.conn.DnsResolver
public

Method Summary

Modifier and TypeMethod and Description
public Socket
connectSocket(final Socket
the socket to connect, as obtained from createSocket. null indicates that a new socket should be created and connected.
socket
,
final InetSocketAddress
the remote address to connect to.
remoteAddress
,
final InetSocketAddress
the local address to bind the socket to, or null for any
localAddress
,
final HttpParams
additional parameters for connecting
params
)

Implements org.apache.http.conn.scheme.SchemeSocketFactory.connectSocket.

Deprecated as a consequence of HttpParams being deprecated.
Connects a socket to the target host with the given remote address.
public Socket
connectSocket(final Socket
the socket to connect, as obtained from createSocket. null indicates that a new socket should be created and connected.
socket
,
final String
the host to connect to
host
,
final int
the port to connect to on the host
port
,
final InetAddress
the local address to bind the socket to, or null for any
localAddress
,
final int
the port on the local machine, 0 or a negative number for any
localPort
,
final HttpParams
additional parameters for connecting
params
)

Implements org.apache.http.conn.scheme.SocketFactory.connectSocket.

Connects a socket to the given host.
public Socket
createSocket(final HttpParams
Optional parameters. Parameters passed to this method will have no effect. This method will create a unconnected instance of Socket class using default constructor.
params
)

Implements org.apache.http.conn.scheme.SchemeSocketFactory.createSocket.

Deprecated as a consequence of HttpParams being deprecated.
Creates a new, unconnected socket.
public Socket
createSocket()

Implements org.apache.http.conn.scheme.SocketFactory.createSocket.

Creates a new, unconnected socket.
public static PlainSocketFactory

Returns:

the default factory
getSocketFactory
()

Deprecated as a consequence of PlainSocketFactory being deprecated.
Gets the default factory.
public final boolean

Returns:

false
isSecure
(final Socket
the connected socket
sock
)

Implements org.apache.http.conn.scheme.SocketFactory.isSecure, org.apache.http.conn.scheme.SchemeSocketFactory.isSecure.

Checks whether a socket connection is secure.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

nameResolverback to summary
private final HostNameResolver nameResolver

Deprecated

as a consequence of HostNameResolver being deprecated. See corresponding docs for further information.

Constructor Detail

PlainSocketFactoryback to summary
public PlainSocketFactory(final HostNameResolver nameResolver)

Deprecated

(4.1) use org.apache.http.conn.DnsResolver

Annotations
@Deprecated
PlainSocketFactoryback to summary
public PlainSocketFactory()

Method Detail

connectSocketback to summary
public Socket connectSocket(final Socket socket, final InetSocketAddress remoteAddress, final InetSocketAddress localAddress, final HttpParams params) throws IOException, ConnectTimeoutException

Implements org.apache.http.conn.scheme.SchemeSocketFactory.connectSocket.

Doc from org.apache.http.conn.scheme.SchemeSocketFactory.connectSocket.

Deprecated

as a consequence of HttpParams being deprecated. See corresponding docs for further information.

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

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

Parameters
socket:Socket

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

remoteAddress:InetSocketAddress

the remote address to connect to.

localAddress:InetSocketAddress

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

params:HttpParams

additional parameters for connecting

Returns:Socket

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

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
ConnectTimeoutException:
if the socket cannot be connected within the time limit defined in the params
Since
4.1
connectSocketback to summary
public Socket connectSocket(final Socket socket, final String host, final int port, final InetAddress localAddress, final int localPort, final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException

Implements org.apache.http.conn.scheme.SocketFactory.connectSocket.

Doc from org.apache.http.conn.scheme.SocketFactory.connectSocket.

Connects a socket to the given host.

Parameters
socket:Socket

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

host:String

the host to connect to

port:int

the port to connect to on the host

localAddress:InetAddress

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

localPort:int

the port on the local machine, 0 or a negative number for any

params:HttpParams

additional parameters for connecting

Returns:Socket

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

Annotations
@Override
@Deprecated
Exceptions
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
createSocketback to summary
public Socket createSocket(final HttpParams params)

Implements org.apache.http.conn.scheme.SchemeSocketFactory.createSocket.

Doc from org.apache.http.conn.scheme.SchemeSocketFactory.createSocket.

Deprecated

as a consequence of HttpParams being deprecated. See corresponding docs for further information.

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

Parameters
params:HttpParams

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:Socket

a new socket

Annotations
@Override
Since
4.1
createSocketback to summary
public Socket createSocket()

Implements org.apache.http.conn.scheme.SocketFactory.createSocket.

Doc from org.apache.http.conn.scheme.SocketFactory.createSocket.

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

Returns:Socket

a new socket

Annotations
@Override
getSocketFactoryback to summary
public static PlainSocketFactory getSocketFactory()

Deprecated

as a consequence of PlainSocketFactory being deprecated. See corresponding docs for further information.

Gets the default factory.

Returns:PlainSocketFactory

the default factory

isSecureback to summary
public final boolean isSecure(final Socket sock)

Implements org.apache.http.conn.scheme.SocketFactory.isSecure, org.apache.http.conn.scheme.SchemeSocketFactory.isSecure.

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

Parameters
sock:Socket

the connected socket

Returns:boolean

false

Annotations
@Override