HTTPClient
Class SocksClient

java.lang.Object
  extended byHTTPClient.SocksClient

class SocksClient
extends Object

This class implements a SOCKS Client. Supports both versions 4 and 5. GSSAPI however is not yet implemented.

Usage is as follows: somewhere in the initialization code (and before the first socket creation call) create a SocksClient instance. Then replace each socket creation call sock = new Socket(host, port); with sock = socks_client.getSocket(host, port); (where socks_client is the above created SocksClient instance). That's all.


Constructor Summary
(package private) SocksClient(String host, int port)
          Creates a new SOCKS Client using the specified host and port for the server.
(package private) SocksClient(String host, int port, int version)
          Creates a new SOCKS Client using the specified host and port for the server.
 
Method Summary
(package private)  Socket getSocket(String host, int port)
          Initiates a connection to the socks server, does the startup protocol and returns a socket ready for talking.
(package private)  Socket getSocket(String host, int port, InetAddress localAddr, int localPort)
          Initiates a connection to the socks server, does the startup protocol and returns a socket ready for talking.
 String toString()
          produces a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SocksClient

SocksClient(String host,
            int port)
Creates a new SOCKS Client using the specified host and port for the server. Will try to establish the SOCKS version used when establishing the first connection.

Parameters:
host - the host the SOCKS server is sitting on.
port - the port the SOCKS server is listening on.

SocksClient

SocksClient(String host,
            int port,
            int version)
      throws SocksException
Creates a new SOCKS Client using the specified host and port for the server.

Parameters:
host - the host the SOCKS server is sitting on.
port - the port the SOCKS server is listening on.
version - the version the SOCKS server is using.
Throws:
SocksException - if the version is invalid (Currently allowed are: 4 and 5).
Method Detail

getSocket

Socket getSocket(String host,
                 int port)
           throws IOException
Initiates a connection to the socks server, does the startup protocol and returns a socket ready for talking.

Parameters:
host - the host you wish to connect to
port - the port you wish to connect to
Returns:
a Socket with a connection via socks to the desired host/port
Throws:
IOException - if any socket operation fails

getSocket

Socket getSocket(String host,
                 int port,
                 InetAddress localAddr,
                 int localPort)
           throws IOException
Initiates a connection to the socks server, does the startup protocol and returns a socket ready for talking.

Parameters:
host - the host you wish to connect to
port - the port you wish to connect to
localAddr - the local address to bind to
localPort - the local port to bind to
Returns:
a Socket with a connection via socks to the desired host/port
Throws:
IOException - if any socket operation fails

toString

public String toString()
produces a string.

Returns:
a string containing the host and port of the socks server