socks
Class ProxyMessage

java.lang.Object
  |
  +--socks.ProxyMessage

public abstract class ProxyMessage
extends java.lang.Object

Abstract class which describes SOCKS4/5 response/request.


Field Summary
 int command
          Request/response code as an int
 java.lang.String host
          Host as string.
 java.net.InetAddress ip
          Host as an IP address
 int port
          Port field of the request/response
 java.lang.String user
          User field for SOCKS4 request messages
 int version
          SOCKS version, or version of the response for SOCKS4
 
Method Summary
 java.net.InetAddress getInetAddress()
          Get the Address field of this message as InetAddress object.
abstract  void read(java.io.InputStream in)
          Initialises Message from the stream.
abstract  void read(java.io.InputStream in, boolean client_mode)
          Initialises Message from the stream.
 java.lang.String toString()
          Get string representaion of this message.
abstract  void write(java.io.OutputStream out)
          Writes the message to the stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ip

public java.net.InetAddress ip
Host as an IP address

version

public int version
SOCKS version, or version of the response for SOCKS4

port

public int port
Port field of the request/response

command

public int command
Request/response code as an int

host

public java.lang.String host
Host as string.

user

public java.lang.String user
User field for SOCKS4 request messages
Method Detail

read

public abstract void read(java.io.InputStream in)
                   throws SocksException,
                          java.io.IOException
Initialises Message from the stream. Reads server response from given stream.
Parameters:
in - Input stream to read response from.
Throws:
SocksException - If server response code is not SOCKS_SUCCESS(0), or if any error with protocol occurs.
java.io.IOException - If any error happens with I/O.

read

public abstract void read(java.io.InputStream in,
                          boolean client_mode)
                   throws SocksException,
                          java.io.IOException
Initialises Message from the stream. Reads server response or client request from given stream.
Parameters:
in - Input stream to read response from.
clinetMode - If true read server response, else read client request.
Throws:
SocksException - If server response code is not SOCKS_SUCCESS(0) and reading in client mode, or if any error with protocol occurs.
java.io.IOException - If any error happens with I/O.

write

public abstract void write(java.io.OutputStream out)
                    throws SocksException,
                           java.io.IOException
Writes the message to the stream.
Parameters:
out - Output stream to which message should be written.

getInetAddress

public java.net.InetAddress getInetAddress()
                                    throws java.net.UnknownHostException
Get the Address field of this message as InetAddress object.
Returns:
Host address or null, if one can't be determined.

toString

public java.lang.String toString()
Get string representaion of this message.
Overrides:
toString in class java.lang.Object
Returns:
string representation of this message.