aleph.comm.udp
Class Connection

java.lang.Object
  |
  +--aleph.comm.udp.Connection
Direct Known Subclasses:
AutoConnection, UDPConnection

public abstract class Connection
extends java.lang.Object

A Connection is a two-way stream of messages between two PEs. This class is abstract because it has two implemenations: the standard one using a reliable packet protocol, and a dummy one that short-circuits messages sent from a PE to itself. Creating a Connection starts a thread that handles incoming messages.


Field Summary
protected  aleph.comm.udp.Connection.MessageHandler handler
           
protected static Counter messagesSent
          Instrumentation: count number of messages sent.
 
Constructor Summary
Connection()
           
 
Method Summary
 void close()
          Clean up at the end.
 void deliver(Packet packet)
          Deliver new packet to connection.
 void flush()
          Push out queued packets.
 boolean ping()
          Is anyone listening?
protected abstract  Message receive()
          Blocking method that pulls in the next message.
abstract  void send(Message message)
          Send'em a message.
 void start()
          Starts thread that processes incoming messages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

messagesSent

protected static Counter messagesSent
Instrumentation: count number of messages sent.

handler

protected aleph.comm.udp.Connection.MessageHandler handler
Constructor Detail

Connection

public Connection()
Method Detail

start

public void start()
Starts thread that processes incoming messages. Must be called after calling the constructor.

deliver

public void deliver(Packet packet)
Deliver new packet to connection.
Parameters:
packet - new arrival.

send

public abstract void send(Message message)
                   throws java.io.IOException
Send'em a message.
Parameters:
message - what to send
Throws:
java.io.IOException - something's wrong

receive

protected abstract Message receive()
                            throws java.io.IOException
Blocking method that pulls in the next message.

close

public void close()
Clean up at the end.

flush

public void flush()
Push out queued packets.

ping

public boolean ping()
Is anyone listening?