|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object network.Neighbor
This class sends and receives packets from a neighbor.
Constructor Summary | |
Neighbor(java.net.Socket socket,
Network network,
boolean transferKey)
Creates a new Neighbor. |
Method Summary | |
void |
connect(java.net.Socket socket,
boolean sendKey)
Connects to a neighbor via passed socket |
void |
finalize()
Called by the garbage collector. |
java.lang.String |
getAddress()
IP Address. |
int |
getLocalPort()
|
java.lang.String |
getName()
Return the name of the neighbor. |
boolean |
isConnected()
Returns whether or not there is a connection open to this Neighbor. |
boolean |
isRemoved()
Indicates whether or not this Neighbor has started yet or has been stopped. |
void |
run()
While the thread is running, deal with the packets coming in from the associated neighbor. |
void |
sendPacket(Packet packet)
Sends the given packet through socket. |
void |
start()
Start the Neighbor Thread. |
void |
stop()
Stop the Neighbor Thread. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Neighbor(java.net.Socket socket, Network network, boolean transferKey) throws java.security.InvalidKeyException, java.security.NoSuchAlgorithmException, javax.crypto.NoSuchPaddingException, java.lang.ClassNotFoundException, java.io.IOException
socket
- The Socket used to read from the neighbor and write to the
neighbor.network
- The Network class that handles this Neighbor.transferKey
- Whether the encryption key should be sent
java.lang.ClassNotFoundException
java.io.IOException
javax.crypto.NoSuchPaddingException
java.security.NoSuchAlgorithmException
java.security.InvalidKeyException
Method Detail |
public java.lang.String getName()
public java.lang.String toString()
public void sendPacket(Packet packet) throws java.security.NoSuchAlgorithmException, javax.crypto.NoSuchPaddingException, java.security.InvalidKeyException, javax.crypto.IllegalBlockSizeException, java.io.IOException
packet
- The packet to be sent.
javax.crypto.NoSuchPaddingException
java.security.NoSuchAlgorithmException
java.security.InvalidKeyException
java.io.IOException
javax.crypto.IllegalBlockSizeException
public void connect(java.net.Socket socket, boolean sendKey) throws java.lang.ClassNotFoundException, java.io.IOException, java.security.NoSuchAlgorithmException, javax.crypto.NoSuchPaddingException, java.security.InvalidKeyException
socket
- The neighbor's Socket objectsendKey
- Whether the encryption key should be sent
java.lang.ClassNotFoundException
java.io.IOException
javax.crypto.NoSuchPaddingException
java.security.NoSuchAlgorithmException
java.security.InvalidKeyException
public void start()
public void stop()
public void run()
run
in interface java.lang.Runnable
public java.lang.String getAddress()
public boolean isConnected()
public int getLocalPort()
public boolean isRemoved()
public void finalize() throws java.lang.Throwable
java.lang.Throwable
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |