public class Destination
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private class |
Destination.DestinationReadThread
This private thread runs forever reading messages by calling "receive" method.
|
Modifier and Type | Field and Description |
---|---|
private boolean |
connected |
private IPPort |
ipport |
private java.io.InputStream |
is |
private MultiPeer |
multiPeerParent |
private java.io.OutputStream |
os |
private java.net.Socket |
socket |
private static int |
TIMEOUT_CONNECTION |
Constructor and Description |
---|
Destination(MultiPeer multipeer)
Create a Destination instance linked to a MultiPeer object.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accepted(java.net.Socket sock)
Consolidate the Destination instance around an "accepted" connection.
|
private void |
close()
Private "close" operation.
|
boolean |
connnect(IPPort ipp)
Connects to the destination end point represented by the passed IPPort object.
|
IPPort |
getIPPort() |
private Message |
receive()
Private reading routine.
|
boolean |
send(Message m)
Send a message to the peer (header and payload buffers of the Message passed)
The information about message length and type is encoded in a prologue handled
at this level (Destination.send() and Destination.receive()).
|
private boolean connected
private IPPort ipport
private java.io.InputStream is
private MultiPeer multiPeerParent
private java.io.OutputStream os
private java.net.Socket socket
private static int TIMEOUT_CONNECTION
Destination(MultiPeer multipeer)
multipeer
- public boolean accepted(java.net.Socket sock)
sock
- is the socket obtained from an "accept" operation (performed in the MultiPeer parent).private void close()
public boolean connnect(IPPort ipp)
ipp
- public IPPort getIPPort()
private Message receive()
public boolean send(Message m)
m
- the Message to send.