CTL.Comm
Class StreamCommunicator

java.lang.Object
  extended by CTL.Comm.Communicator
      extended by CTL.Comm.StreamCommunicator

public class StreamCommunicator
extends Communicator

Simple communicator which write to a stream


Field Summary
private  java.io.ByteArrayOutputStream out
           
 
Constructor Summary
StreamCommunicator()
           
 
Method Summary
 void accept()
           
 void close()
           
 void connect(PeerID remote)
           
 void listen()
           
 java.io.ByteArrayOutputStream output()
           
 PeerID pid()
           
 byte[] recv()
           
 byte[] recv(long len)
           
 void send(byte[] data, long len, boolean debug)
           
 
Methods inherited from class CTL.Comm.Communicator
notifyErr, send, send, send
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

out

private java.io.ByteArrayOutputStream out
Constructor Detail

StreamCommunicator

public StreamCommunicator()
Method Detail

output

public java.io.ByteArrayOutputStream output()

recv

public byte[] recv()
            throws CTLException,
                   java.io.IOException
Specified by:
recv in class Communicator
Throws:
CTLException
java.io.IOException

recv

public byte[] recv(long len)
            throws CTLException,
                   java.io.IOException
Specified by:
recv in class Communicator
Throws:
CTLException
java.io.IOException

send

public void send(byte[] data,
                 long len,
                 boolean debug)
          throws java.io.IOException
Specified by:
send in class Communicator
Throws:
java.io.IOException

pid

public PeerID pid()
Specified by:
pid in class Communicator

accept

public void accept()
            throws java.io.IOException
Specified by:
accept in class Communicator
Throws:
java.io.IOException

connect

public void connect(PeerID remote)
             throws java.io.IOException,
                    java.net.UnknownHostException
Specified by:
connect in class Communicator
Throws:
java.io.IOException
java.net.UnknownHostException

listen

public void listen()
            throws java.io.IOException
Specified by:
listen in class Communicator
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in class Communicator
Throws:
java.io.IOException