@Immutable public class PlainSocketFactory extends java.lang.Object implements SocketFactory, SchemeSocketFactory
The following parameters can be used to customize the behavior of this class:
| 构造器和说明 |
|---|
PlainSocketFactory() |
PlainSocketFactory(HostNameResolver nameResolver)
已过时。
(4.1) use
DnsResolver |
| 限定符和类型 | 方法和说明 |
|---|---|
java.net.Socket |
connectSocket(java.net.Socket socket,
java.net.InetSocketAddress remoteAddress,
java.net.InetSocketAddress localAddress,
HttpParams params)
Connects a socket to the target host with the given remote address.
|
java.net.Socket |
connectSocket(java.net.Socket socket,
java.lang.String host,
int port,
java.net.InetAddress localAddress,
int localPort,
HttpParams params)
|
java.net.Socket |
createSocket()
Creates a new, unconnected socket.
|
java.net.Socket |
createSocket(HttpParams params)
Creates a new, unconnected socket.
|
static PlainSocketFactory |
getSocketFactory()
Gets the default factory.
|
boolean |
isSecure(java.net.Socket sock)
Checks whether a socket connection is secure.
|
@Deprecated public PlainSocketFactory(HostNameResolver nameResolver)
DnsResolverpublic PlainSocketFactory()
public static PlainSocketFactory getSocketFactory()
public java.net.Socket createSocket(HttpParams params)
SchemeSocketFactorySchemeSocketFactory.connectSocket(Socket, InetSocketAddress, InetSocketAddress, HttpParams).createSocket 在接口中 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 java.net.Socket createSocket()
SocketFactoryconnectSocket.createSocket 在接口中 SocketFactorypublic java.net.Socket connectSocket(java.net.Socket socket,
java.net.InetSocketAddress remoteAddress,
java.net.InetSocketAddress localAddress,
HttpParams params)
throws java.io.IOException,
ConnectTimeoutException
SchemeSocketFactoryHttpInetSocketAddress 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.connectSocket 在接口中 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 to.localAddress - the local address to bind the socket to, or
null for anyparams - additional parameters for connectingsock argument if this factory supports
a layered protocol.java.io.IOException - if an I/O error occursjava.net.UnknownHostException - 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 paramsHttpInetSocketAddresspublic final boolean isSecure(java.net.Socket sock)
throws java.lang.IllegalArgumentException
isSecure 在接口中 SchemeSocketFactoryisSecure 在接口中 SocketFactorysock - the connected socketfalsejava.lang.IllegalArgumentException - if the argument is invalid@Deprecated
public java.net.Socket connectSocket(java.net.Socket socket,
java.lang.String host,
int port,
java.net.InetAddress localAddress,
int localPort,
HttpParams params)
throws java.io.IOException,
java.net.UnknownHostException,
ConnectTimeoutException
SocketFactoryconnectSocket 在接口中 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.java.io.IOException - if an I/O error occursjava.net.UnknownHostException - 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 params