edu.cuny.cat.comm
Interface Connection<M extends Message>

Type Parameters:
M - the type of messages that can be transmitted through the connection.
All Known Subinterfaces:
ProactiveCatpConnection, ProactiveConnection<M>, ReactiveCatpConnection, ReactiveConnection<M>
All Known Implementing Classes:
CallBasedCatpConnection, ListenableConnection, QueueBasedCatpConnection, SocketBasedCatpConnection, SocketBasedConnection, TelnetConnection

public interface Connection<M extends Message>

A Message I/O interface for a text message client or server to communicate with its counterpart.

Version:
$Revision: 1.3 $
Author:
Jinzhong Niu

Method Summary
 void close()
          closes this connection.
 java.lang.String getLocalAddressInfo()
           
 java.lang.String getRemoteAddressInfo()
           
 boolean isClosed()
          checks whether the connection is closed or not.
 void open()
          opens the connection before sending or receiving any message.
 void sendMessage(M msg)
          sends a Message through this connection.
 

Method Detail

sendMessage

void sendMessage(M msg)
                 throws CatException
sends a Message through this connection.

Parameters:
msg - message to be sent.
Throws:
java.lang.Exception
CatException

open

void open()
          throws ConnectionException
opens the connection before sending or receiving any message.

Throws:
ConnectionException

close

void close()
           throws ConnectionException
closes this connection.

Throws:
ConnectionException

isClosed

boolean isClosed()
checks whether the connection is closed or not.

Returns:
true if closed; false otherwise.

getRemoteAddressInfo

java.lang.String getRemoteAddressInfo()
Returns:
a string describing the address of the remote end of this connection

getLocalAddressInfo

java.lang.String getLocalAddressInfo()
Returns:
a string describing the address of the local end of this connection