info.jedi.net
Class PingHandler

java.lang.Object
  |
  +--info.jedi.net.DefaultPacketHandler
        |
        +--info.jedi.net.PingHandler

public class PingHandler
extends DefaultPacketHandler


Field Summary
static int PING_HANDLER_NUMBER
          The index that a PingHandler goes at in the MailDaemon
 
Method Summary
 boolean handlePacket(InputPacket packet)
          Handles an incoming ping request.
static void main(java.lang.String[] args)
          Either acts as a ping server (if called with no arguments) or measures the time for 100 JEDI pings to that server (if called with the network address of that server).
 void ping(java.net.InetAddress address, int port)
          Pings a port on a given machine, waiting for a response before returning.
 
Methods inherited from class info.jedi.net.DefaultPacketHandler
handleError, initializePacket, sendPacket
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PING_HANDLER_NUMBER

public static final int PING_HANDLER_NUMBER
The index that a PingHandler goes at in the MailDaemon
Method Detail

handlePacket

public boolean handlePacket(InputPacket packet)
                     throws java.io.IOException
Handles an incoming ping request. It sends a reply packet to the port on the host that sent the request packet.
Overrides:
handlePacket in class DefaultPacketHandler
Returns:
true indicating that processing is complete.
Throws:
java.io.IOException - if there is a problem reading the incoming packet or sending the reply.

ping

public void ping(java.net.InetAddress address,
                 int port)
          throws java.io.IOException
Pings a port on a given machine, waiting for a response before returning. This will hang if the packet never returns.
Throws:
java.io.IOException - if there is an error sending or receiving a ping packet.

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Either acts as a ping server (if called with no arguments) or measures the time for 100 JEDI pings to that server (if called with the network address of that server). This program will exit only if it is a client thread and has successfully completed 100 pings.
Throws:
java.io.IOException - if there is an IO problem with the ping requests or replies.