org.apache.http.conn.scheme
Class PlainSocketFactory

java.lang.Object
  extended by org.apache.http.conn.scheme.PlainSocketFactory
All Implemented Interfaces:
SocketFactory

public final class PlainSocketFactory
extends java.lang.Object
implements SocketFactory

The default class for creating sockets.

Author:
Roland Weber, Michael Becke

Constructor Summary
PlainSocketFactory()
           
PlainSocketFactory(HostNameResolver nameResolver)
           
 
Method Summary
 java.net.Socket connectSocket(java.net.Socket sock, java.lang.String host, int port, java.net.InetAddress localAddress, int localPort, org.apache.http.params.HttpParams params)
          Connects a socket to the given host.
 java.net.Socket createSocket()
          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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlainSocketFactory

public PlainSocketFactory(HostNameResolver nameResolver)

PlainSocketFactory

public PlainSocketFactory()
Method Detail

getSocketFactory

public static PlainSocketFactory getSocketFactory()
Gets the default factory. Usually there should be no reason for creating multiple instances of this class.

Returns:
the default factory

createSocket

public java.net.Socket createSocket()
Description copied from interface: SocketFactory
Creates a new, unconnected socket. The socket should subsequently be passed to connectSocket.

Specified by:
createSocket in interface SocketFactory
Returns:
a new socket

connectSocket

public java.net.Socket connectSocket(java.net.Socket sock,
                                     java.lang.String host,
                                     int port,
                                     java.net.InetAddress localAddress,
                                     int localPort,
                                     org.apache.http.params.HttpParams params)
                              throws java.io.IOException
Description copied from interface: SocketFactory
Connects a socket to the given host.

Specified by:
connectSocket in interface SocketFactory
Parameters:
sock - 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.
Throws:
java.io.IOException - if an I/O error occurs
java.net.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

isSecure

public final boolean isSecure(java.net.Socket sock)
                       throws java.lang.IllegalArgumentException
Checks whether a socket connection is secure. This factory creates plain socket connections which are not considered secure.

Specified by:
isSecure in interface SocketFactory
Parameters:
sock - the connected socket
Returns:
false
Throws:
java.lang.IllegalArgumentException - if the argument is invalid


Copyright © 1999-2008 Apache Software Foundation. All Rights Reserved.