|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpeerbase.PeerConnection
public class PeerConnection
Encapsulates a socket connection to a peer, providing simple, reliable send and receive functionality. All data sent to a peer through this class must be formatted as a PeerMessage object.
Constructor Summary | |
---|---|
PeerConnection(PeerInfo info)
Opens a new connection to the specified peer. |
|
PeerConnection(PeerInfo info,
SocketInterface socket)
Constructs a connection for which a socket has already been opened. |
Method Summary | |
---|---|
void |
close()
Closes the peer connection. |
PeerInfo |
getPeerInfo()
|
PeerMessage |
recvData()
Receives a PeerMessage from the connected peer. |
void |
sendData(PeerMessage msg)
Sends a PeerMessage to the connected peer. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public PeerConnection(PeerInfo info) throws java.io.IOException, java.net.UnknownHostException
info
- the peer node to connect to
java.io.IOException
- if an I/O error occurs
java.net.UnknownHostException
public PeerConnection(PeerInfo info, SocketInterface socket)
info
- socket
- Method Detail |
---|
public void sendData(PeerMessage msg)
msg
- the message object to sendpublic PeerMessage recvData()
public void close()
public PeerInfo getPeerInfo()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |