|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object CTL.Comm.Communicator CTL.Comm.TCPCommunicator
public class TCPCommunicator
TCP/IP communication handling
Field Summary | |
---|---|
private java.net.Socket |
dbgsock
Socket connection to the remote debugger |
private IPaddr |
host
Local IP |
private int |
port
Local port |
private java.nio.channels.Selector |
sel
Selector for this communicator |
private java.net.Socket |
sock
Socket connection to the communication partner |
private java.net.ServerSocket |
ssock
|
Constructor Summary | |
---|---|
TCPCommunicator()
Default constructor |
|
TCPCommunicator(int port)
Constructor for known remote port |
|
TCPCommunicator(java.lang.String host,
int port,
int lport)
Constructor for known remote host and port |
Method Summary | |
---|---|
void |
accept()
Accept connections |
private void |
attachDebugger(PeerID dbgHost)
Initialize connection to debugger |
void |
close()
Close the connection |
void |
connect(PeerID pid)
Connect to peer |
static IPaddr |
determineIP(java.lang.String host,
int port)
Open a temporary TCP connection to determine the outgoing IP for communication with the target IP |
void |
listen()
Listen for new connections |
PeerID |
pid()
Retrieve the PeerID |
byte[] |
recv()
Receive a CTL packet (length is determined from header) |
byte[] |
recv(long len)
Receive a specific amount of data |
void |
send(byte[] data,
long len,
boolean debug)
Send a specific amount of data |
void |
sendDebug(byte[] data)
Send data to the debugger |
void |
setHost(IPaddr host)
Change the contained IP address |
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 |
---|
private IPaddr host
private int port
private java.nio.channels.Selector sel
private java.net.Socket sock
private java.net.Socket dbgsock
private java.net.ServerSocket ssock
Constructor Detail |
---|
public TCPCommunicator()
public TCPCommunicator(java.lang.String host, int port, int lport)
public TCPCommunicator(int port)
Method Detail |
---|
public void setHost(IPaddr host)
host
- Hostpublic void accept() throws java.io.IOException
accept
in class Communicator
java.io.IOException
public void listen() throws java.io.IOException
listen
in class Communicator
java.io.IOException
public PeerID pid()
pid
in class Communicator
public void connect(PeerID pid) throws java.net.UnknownHostException, java.io.IOException
connect
in class Communicator
pid
- PeerID of remote host
java.net.UnknownHostException
java.io.IOException
private void attachDebugger(PeerID dbgHost) throws java.net.UnknownHostException, java.io.IOException
dbgHost
- Location of the debugger
java.net.UnknownHostException
java.io.IOException
public void close() throws java.io.IOException
close
in class Communicator
java.io.IOException
public void send(byte[] data, long len, boolean debug) throws java.io.IOException
send
in class Communicator
data
- Bytes to sendlen
- Number of bytes to senddebug
- Whether or not to send the data to the debugger
java.io.IOException
public void sendDebug(byte[] data) throws java.io.IOException
data
- Bytes to send
java.io.IOException
public byte[] recv(long len) throws java.io.IOException, CTLException
recv
in class Communicator
len
- Number of bytes to receive
java.io.IOException
CTLException
public byte[] recv() throws java.io.IOException, CTLException
recv
in class Communicator
java.io.IOException
CTLException
public static IPaddr determineIP(java.lang.String host, int port)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |