@Immutable public class PlainSocketFactory extends Object implements SocketFactory, SchemeSocketFactory
The following parameters can be used to customize the behavior of this class:
CoreConnectionPNames.CONNECTION_TIMEOUTCoreConnectionPNames.SO_REUSEADDR| Constructor and Description |
|---|
PlainSocketFactory() |
PlainSocketFactory(HostNameResolver nameResolver)
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
Socket |
connectSocket(Socket socket,
InetSocketAddress remoteAddress,
InetSocketAddress localAddress,
org.apache.http.params.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,
org.apache.http.params.HttpParams params)
|
Socket |
createSocket()
Creates a new, unconnected socket.
|
Socket |
createSocket(org.apache.http.params.HttpParams params)
Creates a new, unconnected socket.
|
static PlainSocketFactory |
getSocketFactory()
Gets the default factory.
|
boolean |
isSecure(Socket sock)
Checks whether a socket connection is secure.
|
@Deprecated public PlainSocketFactory(HostNameResolver nameResolver)
public PlainSocketFactory()
public static PlainSocketFactory getSocketFactory()
public Socket createSocket(org.apache.http.params.HttpParams params)
SchemeSocketFactorySchemeSocketFactory.connectSocket(Socket, InetSocketAddress, InetSocketAddress, HttpParams).createSocket in interface SchemeSocketFactoryparams - Optional parameters. Parameters passed to this method will have no effect.
This method will create a unconnected instance of Socket class
using default constructor.public Socket createSocket()
SocketFactoryconnectSocket.createSocket in interface SocketFactorypublic Socket connectSocket(Socket socket, InetSocketAddress remoteAddress, InetSocketAddress localAddress, org.apache.http.params.HttpParams params) throws IOException, ConnectTimeoutException
SchemeSocketFactoryconnectSocket in interface SchemeSocketFactorysocket - 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 tolocalAddress - the local address to bind the socket to, or
null for anyparams - additional parameters for connectingsock argument if this factory supports
a layered protocol.IOException - if an I/O error occursUnknownHostException - if the IP address of the target host
can not be determinedConnectTimeoutException - if the socket cannot be connected
within the time limit defined in the paramspublic final boolean isSecure(Socket sock) throws IllegalArgumentException
isSecure in interface SchemeSocketFactoryisSecure in interface SocketFactorysock - the connected socketfalseIllegalArgumentException - if the argument is invalid@Deprecated public Socket connectSocket(Socket socket, String host, int port, InetAddress localAddress, int localPort, org.apache.http.params.HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException
SocketFactoryconnectSocket in interface SocketFactorysocket - the socket to connect, as obtained from
createSocket.
null indicates that a new socket
should be created and connected.host - the host to connect toport - the port to connect to on the hostlocalAddress - the local address to bind the socket to, or
null for anylocalPort - the port on the local machine,
0 or a negative number for anyparams - additional parameters for connectingsock argument if this factory supports
a layered protocol.IOException - if an I/O error occursUnknownHostException - if the IP address of the target host
can not be determinedConnectTimeoutException - if the socket cannot be connected
within the time limit defined in the paramsCopyright © 1999-2012 The Apache Software Foundation. All Rights Reserved.