utilities
Class Connection

java.lang.Object
  |
  +--utilities.Connection

public class Connection
extends java.lang.Object

Communicate uses this class to store connection information.


Field Summary
static int KQML
           
static int LENGTHPREFIX
           
static int RAW
           
 
Constructor Summary
Connection(java.net.Socket s, int t, boolean a)
          Constructor, uses default type-specific delimiters.
Connection(java.net.Socket s, int t, java.lang.String d, boolean a)
          Constructor
 
Method Summary
 void close()
          Closes the currently open socket
 java.lang.String getDelim()
          Gets the message delimiter
 java.io.BufferedReader getInput()
          Returns the input reader attached to the socket
 java.lang.String getLocalHostName()
          Returns the host name of the local machine
 int getLocalPort()
          Returns the local port number
 java.io.BufferedWriter getOutput()
          Returns the input reader attached to the socket
 java.lang.String getRemoteHostName()
          Returns the host name of machine attached to this connection
 int getRemotePort()
          Returns the remote port number
 java.net.Socket getSocket()
          Gets the socket
 int getType()
          Returns the connection (pseudo-protocol) type
 boolean isDefault()
          Gets the default state
 void setDefault(boolean d)
          Sets the default state
 void setDelim(java.lang.String d)
          Sets the message delimiter
 void setType(int t)
          Sets the connection (pseudo-protocol) type
 java.lang.String toString()
          Stringify me
 boolean wasAccepted()
          Tells weather this connection was accepted (e.g.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RAW

public static final int RAW

KQML

public static final int KQML

LENGTHPREFIX

public static final int LENGTHPREFIX
Constructor Detail

Connection

public Connection(java.net.Socket s,
                  int t,
                  boolean a)
           throws java.io.IOException
Constructor, uses default type-specific delimiters.
Parameters:
s - The socket the connection is on
t - The type of connection. RAW, KQML, or LENGTHPREFIX.
a - Did we accepted this connection? (we initiated if false)

Connection

public Connection(java.net.Socket s,
                  int t,
                  java.lang.String d,
                  boolean a)
           throws java.io.IOException
Constructor
Parameters:
s - The socket the connection is on
t - The type of connection
d - The message delimieter
a - Did we accepted this connection? (we initiated if false)
Method Detail

getType

public int getType()
Returns the connection (pseudo-protocol) type
Returns:
the type

setType

public void setType(int t)
Sets the connection (pseudo-protocol) type
Parameters:
t - the new type

getRemoteHostName

public java.lang.String getRemoteHostName()
Returns the host name of machine attached to this connection
Returns:
The host name

getLocalHostName

public java.lang.String getLocalHostName()
Returns the host name of the local machine
Returns:
The host name

getRemotePort

public int getRemotePort()
Returns the remote port number
Returns:
The port number

getLocalPort

public int getLocalPort()
Returns the local port number
Returns:
The port number

getInput

public java.io.BufferedReader getInput()
Returns the input reader attached to the socket
Returns:
The stream

getOutput

public java.io.BufferedWriter getOutput()
Returns the input reader attached to the socket
Returns:
The stream

getSocket

public java.net.Socket getSocket()
Gets the socket
Returns:
The socket

setDelim

public void setDelim(java.lang.String d)
Sets the message delimiter
Parameters:
d - The message delimiter
See Also:
Message.receive(java.io.BufferedReader, java.lang.String)

getDelim

public java.lang.String getDelim()
Gets the message delimiter
Returns:
the message delimiter

close

public void close()
           throws java.io.IOException
Closes the currently open socket

wasAccepted

public boolean wasAccepted()
Tells weather this connection was accepted (e.g. picked up by a server port listener) or established (e.g. actively opened by the local agent).

setDefault

public void setDefault(boolean d)
Sets the default state
Parameters:
d - The new state

isDefault

public boolean isDefault()
Gets the default state

toString

public java.lang.String toString()
Stringify me
Overrides:
toString in class java.lang.Object
Returns:
A string representation of the connection