com.eyebolt.iplib
Class IPManager

java.lang.Object
  |
  +--com.eyebolt.iplib.IPManager

public class IPManager
extends java.lang.Object

Main entry point for the iplib library.

Version:
$Revision: 1.4 $, 4 Jan 1997
Author:
John Gardner

Inner Class Summary
(package private)  class IPManager.ShutdownRunner
           
 
Field Summary
static int BASE
          Constructor arg to select BASE tcp/ip messaging.
private  java.util.Vector connections
          array of connections that have been made
private  int datatype
           
static int ERR_PORT_IN_USE
          Error returned by listen when the port is not available
static int HTTP_TUNNEL
          Constructor arg to select HTTP tcp/ip messaging.
private  java.util.Vector listenThreads
          array of threads, each listening on a port
(package private)  java.util.Vector msgReplies
          mapping from message ID to reply
private  IPCallback onreceive
           
private  IPAddress proxyAddress
          Address of proxy server.
static int RAW
          Constructor arg to select RAW TCP/IP
static int SUCCESS
          Value returned when an operation runs successfully
static int TEXT
          Constructor arg to select Line (cr/lf) oriented TCP/IP
private  RecvThreadMgr threadManager
          handler for pool of receive threads
private  java.util.Vector timeoutReplies
          mapping from timeout to reply (for replyvulture)
private  VultureThread vulture
           
 
Constructor Summary
IPManager(int reqtype)
          No argument constructor
 
Method Summary
(package private)  void addKey(IPKey key)
          Adds a feature to the Key attribute of the IPManager object
(package private)  void addReply(IPReply rep)
          Adds a reply to the IPManager object
 IPKey connect(IPAddress address)
          Connect to a given address; check the status of the ConnKey to determine if the connection was successful.
 void disconnect(IPKey key)
          Disconnect the connection represented by this connection key.
 void endListen(IPAddress address)
          Cease listening for new connections.
(package private)  int getDatatype()
          Get datatype/data transfer mode for this IPManager
(package private)  IPCallback getOnReceive()
          Get onrecieve callback
(package private)  IPReply getReply(int msgID)
          Fetch a reply to a given message
 int listen(IPAddress address, IPCallback callback)
          Begin listening for new TCP/IP connections on the given address.
 int onReceive(IPCallback cb)
          Specify a default callback function for messages received.
 void setHttpProxy(IPAddress proxyAddress)
          Specify the address of an HTTP proxy server, for HTTP_TUNNEL mode.
 void shutdown()
          Shutdown IPManager; disconnect all connections, clean up.
private  void trace(java.lang.String s)
          Write a trace message to standard output stream.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

RAW

public static final int RAW
Constructor arg to select RAW TCP/IP

TEXT

public static final int TEXT
Constructor arg to select Line (cr/lf) oriented TCP/IP

BASE

public static final int BASE
Constructor arg to select BASE tcp/ip messaging. Proprietary header, automatic matching of request/responses.

HTTP_TUNNEL

public static final int HTTP_TUNNEL
Constructor arg to select HTTP tcp/ip messaging. This allows tunneling through firewalls via HTTP encapsulation.

SUCCESS

public static final int SUCCESS
Value returned when an operation runs successfully

ERR_PORT_IN_USE

public static final int ERR_PORT_IN_USE
Error returned by listen when the port is not available

proxyAddress

private IPAddress proxyAddress
Address of proxy server.

connections

private java.util.Vector connections
array of connections that have been made

timeoutReplies

private java.util.Vector timeoutReplies
mapping from timeout to reply (for replyvulture)

msgReplies

java.util.Vector msgReplies
mapping from message ID to reply

threadManager

private RecvThreadMgr threadManager
handler for pool of receive threads

vulture

private VultureThread vulture

datatype

private int datatype

onreceive

private IPCallback onreceive

listenThreads

private java.util.Vector listenThreads
array of threads, each listening on a port
Constructor Detail

IPManager

public IPManager(int reqtype)
No argument constructor
Parameters:
reqtype - Specifies the kind of connections this manager will be making; can be BASE, TEXT, or RAW. If type is BASE, messages will have fixed length headers prepended that will specify the size of message, and the other end will repackage the message back, if it was broken up in transit. If the type is text, messages will be expected to be terminated with carriage returns. Raw will just return each chunk of data that is received.
Method Detail

setHttpProxy

public void setHttpProxy(IPAddress proxyAddress)
Specify the address of an HTTP proxy server, for HTTP_TUNNEL mode.
Parameters:
cb - Description of Parameter
Returns:
Description of the Returned Value

onReceive

public int onReceive(IPCallback cb)
Specify a default callback function for messages received. This is for connections that don't specify their own callback, or for connection information, for example notifications of broken connections.
Parameters:
cb - Description of Parameter
Returns:
Description of the Returned Value

connect

public IPKey connect(IPAddress address)
              throws java.io.IOException
Connect to a given address; check the status of the ConnKey to determine if the connection was successful.
Parameters:
address - address to which the manager should connect
Returns:
a connection key identifying this connection
Throws:
java.io.IOException - on network error

disconnect

public void disconnect(IPKey key)
Disconnect the connection represented by this connection key.
Parameters:
key - key representing the connection to disconnect.

listen

public int listen(IPAddress address,
                  IPCallback callback)
Begin listening for new TCP/IP connections on the given address.
Parameters:
address - The ip and port on which to listen for connections.
callback - a callback to receive notification upon receiving a connnection.
Returns:
an error code if the listen was unsuccessful, or SUCCESS

endListen

public void endListen(IPAddress address)
Cease listening for new connections.
Parameters:
address - address on which the listen was started.

shutdown

public void shutdown()
Shutdown IPManager; disconnect all connections, clean up. This will also be called on a shutdown hook, if it hasn't already been shut down.
Parameters:
key - key representing the connection to disconnect.

getReply

IPReply getReply(int msgID)
Fetch a reply to a given message
Parameters:
msgID - Id of the message we want a reply for
Returns:
The Reply value

getOnReceive

IPCallback getOnReceive()
Get onrecieve callback
Returns:
onreceive callback for this ipmanager

getDatatype

int getDatatype()
Get datatype/data transfer mode for this IPManager
Returns:
onreceive callback for this ipmanager

addReply

void addReply(IPReply rep)
Adds a reply to the IPManager object
Parameters:
rep - The feature to be added to the Reply attribute

addKey

void addKey(IPKey key)
      throws java.io.IOException
Adds a feature to the Key attribute of the IPManager object
Parameters:
key - The feature to be added to the Key attribute
Throws:
java.io.IOException - Description of Exception

trace

private final void trace(java.lang.String s)
Write a trace message to standard output stream.
Parameters:
s - string to write


Copyright © 2001 Eyebolt, Inc.