Package org.apache.http.conn.scheme
Class PlainSocketFactory
java.lang.Object
org.apache.http.conn.scheme.PlainSocketFactory
- All Implemented Interfaces:
SocketFactory
public final class PlainSocketFactory extends Object implements SocketFactory
The default class for creating sockets.
- Author:
- Roland Weber, Michael Becke
-
Constructor Summary
Constructors Constructor Description PlainSocketFactory()PlainSocketFactory(HostNameResolver nameResolver) -
Method Summary
Modifier and Type Method Description SocketconnectSocket(Socket sock, String host, int port, InetAddress localAddress, int localPort, HttpParams params)Connects a socket to the given host.SocketcreateSocket()Creates a new, unconnected socket.booleanequals(Object obj)Compares this factory with an object.static PlainSocketFactorygetSocketFactory()Gets the singleton instance of this class.inthashCode()Obtains a hash code for this object.booleanisSecure(Socket sock)Checks whether a socket connection is secure.
-
Constructor Details
-
PlainSocketFactory
-
PlainSocketFactory
public PlainSocketFactory()
-
-
Method Details
-
getSocketFactory
Gets the singleton instance of this class.- Returns:
- the one and only plain socket factory
-
createSocket
Description copied from interface:SocketFactoryCreates a new, unconnected socket. The socket should subsequently be passed toconnectSocket.- Specified by:
createSocketin interfaceSocketFactory- Returns:
- a new socket
-
connectSocket
public Socket connectSocket(Socket sock, String host, int port, InetAddress localAddress, int localPort, HttpParams params) throws IOExceptionDescription copied from interface:SocketFactoryConnects a socket to the given host.- Specified by:
connectSocketin interfaceSocketFactory- Parameters:
sock- the socket to connect, as obtained fromcreateSocket.nullindicates 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, ornullfor anylocalPort- the port on the local machine, 0 or a negative number for anyparams- additionalparametersfor connecting- Returns:
- the connected socket. The returned object may be different
from the
sockargument if this factory supports a layered protocol. - Throws:
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 theparams
-
isSecure
Checks whether a socket connection is secure. This factory creates plain socket connections which are not considered secure.- Specified by:
isSecurein interfaceSocketFactory- Parameters:
sock- the connected socket- Returns:
false- Throws:
IllegalArgumentException- if the argument is invalid
-
equals
Compares this factory with an object. There is only one instance of this class.- Overrides:
equalsin classObject- Parameters:
obj- the object to compare with- Returns:
- iff the argument is this object
- See Also:
Object.hashCode()
-
hashCode
public int hashCode()Obtains a hash code for this object. All instances of this class have the same hash code. There is only one instance of this class.- Overrides:
hashCodein classObject- Returns:
- this object's hash code.
- See Also:
Object.equals(java.lang.Object)
-