aleph.comm.tcp
Class TCPConnection

java.lang.Object
  |
  +--aleph.comm.tcp.Connection
        |
        +--aleph.comm.tcp.TCPConnection

public class TCPConnection
extends Connection

A TCPConnection encapsulates a stream socket to a remote PE.

See Also:
Connection, AutoConnection

Fields inherited from class aleph.comm.tcp.Connection
messagesSent
 
Constructor Summary
TCPConnection(Address destination)
          Constructor for outgoing connection.
TCPConnection(java.net.Socket socket)
          Constructor for incoming connection.
 
Method Summary
 void close()
          Close socket and let thread die naturally.
 void flush()
          Flush output stream.
 boolean ping()
          Ping output stream.
protected  Message receive()
          Pull in next message.
 void send(Message message)
          Send a message on this connection.
 
Methods inherited from class aleph.comm.tcp.Connection
start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TCPConnection

public TCPConnection(java.net.Socket socket)
Constructor for incoming connection.
Parameters:
socket - use this socket

TCPConnection

public TCPConnection(Address destination)
Constructor for outgoing connection.
Parameters:
destination - partner's Address
localHost - my address
Method Detail

close

public void close()
Close socket and let thread die naturally.
Overrides:
close in class Connection

flush

public void flush()
Flush output stream.
Overrides:
flush in class Connection

ping

public boolean ping()
Ping output stream.
Overrides:
ping in class Connection

send

public void send(Message message)
Send a message on this connection. Synchronized for concurrent sends.
Parameters:
message - what to send
Overrides:
send in class Connection

receive

protected Message receive()
                   throws java.io.IOException
Pull in next message. Blocking and unsynchronized.
Overrides:
receive in class Connection