|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectprotocol.DatagramChannel
public class DatagramChannel
Binds the UDP port. Each peer is associated with one DatagramChannel object.
Field Summary | |
---|---|
private static int |
INBOUND_UDP_BUFFER_SIZE
The default size for the inbound UDP buffer |
private int |
localPort
The local UDP port where datagram socket is bound |
private java.lang.Thread |
pduReceiverThread
The UDP receiver worker thread |
private RemotePeer |
remotePeer
Current remote peer receiving datagrams from UDP socket |
private boolean |
running
Indicates that worker thread should be running (receiving datagrams) |
private java.net.DatagramSocket |
udpReceiver
The UDP receiver socket |
private SymmetricCipher |
usedPduCipher
Currently used symmetric cipher |
Constructor Summary | |
---|---|
DatagramChannel(int localPort)
Constructor for the DatagramChannel object |
Method Summary | |
---|---|
void |
addNewPeer(RemotePeer remotePeer)
Adds new peer to receive incoming PDUs |
int |
getLocalPort()
Returns used local UDP port. |
RemotePeer |
getRemotePeer()
Returns the remote peer |
SymmetricCipher |
getUsedSymmetricCipher()
Gets current cipher used for PDU ciphering |
boolean |
hasRemotePeer()
Returns if there is active remote peer |
boolean |
isPearDead(int maxIdleTimeMillis)
Returns if peer seems to be dead (we are not receiving PDUs from it). |
protected void |
packetDump(byte[] octets,
int len,
java.net.InetAddress addr,
int port,
boolean incoming)
Dumps information of a frame (in bytes) to standard error. |
void |
removePeer()
Detaches peer and all its call from the UDP receiver |
void |
run()
Receives (and deciphers) PDUs from remote peers in a loop. |
void |
send(OctetBuffer pdu,
java.net.InetAddress peerAddr,
int peerPort)
Encrypts and sends PDUs to remote peer |
void |
stop()
Stops PDU receiver thread |
void |
useSymmetricCipher(SymmetricCipher cipherEngine)
Sets cipher to be used for PDU ciphering |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final int INBOUND_UDP_BUFFER_SIZE
private int localPort
private java.net.DatagramSocket udpReceiver
private java.lang.Thread pduReceiverThread
private volatile boolean running
private RemotePeer remotePeer
private SymmetricCipher usedPduCipher
Constructor Detail |
---|
public DatagramChannel(int localPort)
localPort
- local UDP port receiving peer's PDUs
java.net.SocketException
- Thrown if the UDP socket cannot be created
java.net.UnknownHostException
- Thrown if the remoteHost cannot be resolvedMethod Detail |
---|
public int getLocalPort()
public void useSymmetricCipher(SymmetricCipher cipherEngine)
public SymmetricCipher getUsedSymmetricCipher()
public void addNewPeer(RemotePeer remotePeer)
public boolean hasRemotePeer()
public RemotePeer getRemotePeer()
public boolean isPearDead(int maxIdleTimeMillis)
public void removePeer()
public void stop()
public void run()
run
in interface java.lang.Runnable
public void send(OctetBuffer pdu, java.net.InetAddress peerAddr, int peerPort)
protected void packetDump(byte[] octets, int len, java.net.InetAddress addr, int port, boolean incoming)
octets
- The octets of the in- or outgoing PDUlen
- The size of PDUaddr
- The remote host addressport
- The port numberincoming
- Indicates if it is inbound (true) or outgoing (false) PDU
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |