socks
Class SocksServerSocket

java.lang.Object
  |
  +--java.net.ServerSocket
        |
        +--socks.SocksServerSocket

public class SocksServerSocket
extends java.net.ServerSocket

SocksServerSocket allows to accept connections from one particular host through the SOCKS4 or SOCKS5 proxy.


Constructor Summary
SocksServerSocket(java.net.InetAddress ip, int port)
          Creates ServerSocket capable of accepting one connection through the firewall, uses default Proxy.
SocksServerSocket(Proxy p, java.net.InetAddress ip, int port)
          Creates ServerSocket capable of accepting one connection through the firewall, uses given proxy.
SocksServerSocket(Proxy p, java.lang.String host, int port)
          Creates ServerSocket capable of accepting one connection through the firewall, uses given proxy.
SocksServerSocket(java.lang.String host, int port)
          Creates ServerSocket capable of accepting one connection through the firewall, uses default Proxy.
 
Method Summary
 java.net.Socket accept()
          Accepts the incoming connection.
 void close()
          Closes the connection to proxy if socket have not been accepted, if the direct connection is used, closes direct ServerSocket.
 java.lang.String getHost()
          Get the name of the host proxy is using to listen for incoming connection.
 java.net.InetAddress getInetAddress()
          Get address assigned by proxy to listen for incomming connections, or the local machine address if doing direct connection.
 int getLocalPort()
          Get port assigned by proxy to listen for incoming connections, or the port chosen by local system, if accepting directly.
 void setSoTimeout(int timeout)
          Set Timeout.
 
Methods inherited from class java.net.ServerSocket
getSoTimeout, setSocketFactory, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SocksServerSocket

public SocksServerSocket(java.lang.String host,
                         int port)
                  throws SocksException,
                         java.net.UnknownHostException,
                         java.io.IOException
Creates ServerSocket capable of accepting one connection through the firewall, uses default Proxy.
Parameters:
host - Host from which the connection should be recieved.
port - Port number of the primary connection.

SocksServerSocket

public SocksServerSocket(Proxy p,
                         java.lang.String host,
                         int port)
                  throws SocksException,
                         java.net.UnknownHostException,
                         java.io.IOException
Creates ServerSocket capable of accepting one connection through the firewall, uses given proxy.
Parameters:
p - Proxy object to use.
host - Host from which the connection should be recieved.
port - Port number of the primary connection.

SocksServerSocket

public SocksServerSocket(java.net.InetAddress ip,
                         int port)
                  throws SocksException,
                         java.io.IOException
Creates ServerSocket capable of accepting one connection through the firewall, uses default Proxy.
Parameters:
ip - Host from which the connection should be recieved.
port - Port number of the primary connection.

SocksServerSocket

public SocksServerSocket(Proxy p,
                         java.net.InetAddress ip,
                         int port)
                  throws SocksException,
                         java.io.IOException
Creates ServerSocket capable of accepting one connection through the firewall, uses given proxy.
Parameters:
p - Proxy object to use.
ip - Host from which the connection should be recieved.
port - Port number of the primary connection.
Method Detail

accept

public java.net.Socket accept()
                       throws java.io.IOException
Accepts the incoming connection.
Overrides:
accept in class java.net.ServerSocket

close

public void close()
           throws java.io.IOException
Closes the connection to proxy if socket have not been accepted, if the direct connection is used, closes direct ServerSocket. If the client socket have been allready accepted, does nothing.
Overrides:
close in class java.net.ServerSocket

getHost

public java.lang.String getHost()
Get the name of the host proxy is using to listen for incoming connection.

Usefull when address is returned by proxy as the hostname.

Returns:
the hostname of the address proxy is using to listen for incoming connection.

getInetAddress

public java.net.InetAddress getInetAddress()
Get address assigned by proxy to listen for incomming connections, or the local machine address if doing direct connection.
Overrides:
getInetAddress in class java.net.ServerSocket

getLocalPort

public int getLocalPort()
Get port assigned by proxy to listen for incoming connections, or the port chosen by local system, if accepting directly.
Overrides:
getLocalPort in class java.net.ServerSocket

setSoTimeout

public void setSoTimeout(int timeout)
                  throws java.net.SocketException
Set Timeout.
Overrides:
setSoTimeout in class java.net.ServerSocket
Parameters:
timeout - Amount of time in milliseconds, accept should wait for incoming connection before failing with exception. Zero timeout implies infinity.