java2gomd
Class GomdClient

java.lang.Object
  extended byjava2gomd.GomdClient

public class GomdClient
extends java.lang.Object

The connection to the Gomd daemon

See Also:
Hashtable

Constructor Summary
GomdClient(java.lang.String gomd_hostname, int gomd_port)
          Creates a GomdClient, the connection to the Gomd daemon
 
Method Summary
 void close()
          Detaches the input and output streams and then closes the connection.
 boolean connect()
          Connects to the remote Gomd and attaches the input and output streams
protected  void finalize()
          Called by java's garbage collector when removed Calls close() to close the connection neatly.
 long getBytesReceived()
          Returns the number of bytes received by this connection
 long getBytesSent()
          Returns the number of bytes sent by this connection
 java.lang.String[] grep(java.lang.String pattern)
          Filters the user-specified value from Gomd's reply
 void send(java.lang.String data)
          Sends a user-specified string
 void setAddress(java.lang.String hostname, int port)
          Sets the address and port of the Gomd to connect to.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GomdClient

public GomdClient(java.lang.String gomd_hostname,
                  int gomd_port)
           throws java.io.IOException
Creates a GomdClient, the connection to the Gomd daemon

Parameters:
gomd_hostname - The hostname or IPv4 address to connect to
gomd_port - The port on wich Gomd is listening
Method Detail

setAddress

public void setAddress(java.lang.String hostname,
                       int port)
Sets the address and port of the Gomd to connect to.

Parameters:
hostname - The hostname or IPv4-address to connect to
port - The port on wich Gomd is listening

connect

public boolean connect()
                throws java.net.UnknownHostException,
                       java.io.IOException
Connects to the remote Gomd and attaches the input and output streams

Returns:
boolean respresenting failure(1) or success(0) of connecting.
Throws:
java.net.UnknownHostException
java.io.IOException

finalize

protected void finalize()
                 throws java.io.IOException
Called by java's garbage collector when removed Calls close() to close the connection neatly.

Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Detaches the input and output streams and then closes the connection.

Throws:
java.io.IOException

send

public void send(java.lang.String data)
Sends a user-specified string

Parameters:
data - The String to send to Gomd

grep

public java.lang.String[] grep(java.lang.String pattern)
                        throws java.io.IOException
Filters the user-specified value from Gomd's reply

Parameters:
pattern - The value to return
Returns:
String[] listing all the value's returned by Gomd Example:
Returns {1,2,3,4,5,6} when called like
GomdClient.send("get pidlist 257");
GomdClient.grep("PIDS_LIST");

and Gomd Returns ($GARBAGE)(PIDS_LIST:1,2,3,4,5,6)($GARBAGE)
Throws:
java.io.IOException

getBytesReceived

public long getBytesReceived()
Returns the number of bytes received by this connection

Returns:
long representing the number of bytes received by this connection.

getBytesSent

public long getBytesSent()
Returns the number of bytes sent by this connection

Returns:
long representing the number of bytes sent by this connection.