example
Class HttpClient

java.lang.Object
  |
  +--example.HttpClient
All Implemented Interfaces:
java.lang.Runnable

public class HttpClient
extends java.lang.Object
implements java.lang.Runnable

Implementation of a basic HTTP client for Firewall tunneling. The client supports both Client->Server and Server->Client communication.


Field Summary
static int DATA
           
static int PENDING
           
 
Constructor Summary
HttpClient(java.lang.String url)
          Creates a new HttpClient instance configured to connect to the server specified in the url parameter.
 
Method Summary
 void addHttpListener(HttpListener l)
          Adds the HttpListener.
 void removeHttpListener(HttpListener l)
          Removes the HttpListener.
 void run()
          Thread used to maintain the pending connection
 byte[] send(byte[] data)
          Sends a message to the server
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PENDING

public static final int PENDING
See Also:
Constant Field Values

DATA

public static final int DATA
See Also:
Constant Field Values
Constructor Detail

HttpClient

public HttpClient(java.lang.String url)
Creates a new HttpClient instance configured to connect to the server specified in the url parameter.

Parameters:
url - URL of the server, example http://bogus:9000
Method Detail

removeHttpListener

public void removeHttpListener(HttpListener l)
Removes the HttpListener. The pending connection is stopped, so the client won't receive any more messages from the server

Parameters:
l - HttpListener to remove
Returns:
void

addHttpListener

public void addHttpListener(HttpListener l)
                     throws java.util.TooManyListenersException
Adds the HttpListener. The pending connection is started, so the client will receive messages from the server.

Parameters:
l - HttpListener to remove
Returns:
void
Throws:
java.util.TooManyListenersException - Thrown if more then one HttpListener is added.

run

public void run()
Thread used to maintain the pending connection

Specified by:
run in interface java.lang.Runnable
Returns:
void

send

public byte[] send(byte[] data)
            throws java.io.IOException
Sends a message to the server

Parameters:
data - Array of bytes to send
Returns:
void
Throws:
java.io.IOException - Thrown if a problem occurs while sending the message