Savarese.Org

example
Class Ping.Pinger

java.lang.Object
  extended by example.Ping.Pinger
Direct Known Subclasses:
Ping.PingerIPv6
Enclosing class:
Ping

public static class Ping.Pinger
extends java.lang.Object


Field Summary
protected  int dataOffset
           
protected  int identifier
           
protected  int length
           
protected  Ping.EchoReplyListener listener
           
protected  int offset
           
protected  byte[] recvData
           
protected  org.savarese.vserv.tcpip.ICMPEchoPacket recvPacket
           
protected  int replyType
           
protected  int requestType
           
protected  byte[] sendData
           
protected  org.savarese.vserv.tcpip.ICMPEchoPacket sendPacket
           
protected  int sequence
           
protected  RawSocket socket
           
protected  byte[] srcAddress
           
 
Constructor Summary
  Ping.Pinger(int id)
           
protected Ping.Pinger(int id, int protocolFamily, int protocol)
           
 
Method Summary
 void close()
          Closes the raw socket opened by the constructor.
protected  void computeSendChecksum(java.net.InetAddress host)
           
 int getRequestDataLength()
           
 int getRequestPacketLength()
           
 long ping(java.net.InetAddress host)
          Issues a synchronous ping.
 void receive()
           
 void receiveEchoReply()
           
 void sendEchoRequest(java.net.InetAddress host)
           
 void setEchoReplyListener(Ping.EchoReplyListener l)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

socket

protected RawSocket socket

sendPacket

protected org.savarese.vserv.tcpip.ICMPEchoPacket sendPacket

recvPacket

protected org.savarese.vserv.tcpip.ICMPEchoPacket recvPacket

offset

protected int offset

length

protected int length

dataOffset

protected int dataOffset

requestType

protected int requestType

replyType

protected int replyType

sendData

protected byte[] sendData

recvData

protected byte[] recvData

srcAddress

protected byte[] srcAddress

sequence

protected int sequence

identifier

protected int identifier

listener

protected Ping.EchoReplyListener listener
Constructor Detail

Ping.Pinger

protected Ping.Pinger(int id,
                      int protocolFamily,
                      int protocol)
               throws java.io.IOException
Throws:
java.io.IOException

Ping.Pinger

public Ping.Pinger(int id)
            throws java.io.IOException
Throws:
java.io.IOException
Method Detail

computeSendChecksum

protected void computeSendChecksum(java.net.InetAddress host)
                            throws java.io.IOException
Throws:
java.io.IOException

setEchoReplyListener

public void setEchoReplyListener(Ping.EchoReplyListener l)

close

public void close()
           throws java.io.IOException
Closes the raw socket opened by the constructor. After calling this method, the object cannot be used.

Throws:
java.io.IOException

sendEchoRequest

public void sendEchoRequest(java.net.InetAddress host)
                     throws java.io.IOException
Throws:
java.io.IOException

receive

public void receive()
             throws java.io.IOException
Throws:
java.io.IOException

receiveEchoReply

public void receiveEchoReply()
                      throws java.io.IOException
Throws:
java.io.IOException

ping

public long ping(java.net.InetAddress host)
          throws java.io.IOException
Issues a synchronous ping.

Parameters:
host - The host to ping.
Returns:
The round trip time in nanoseconds.
Throws:
java.io.IOException

getRequestDataLength

public int getRequestDataLength()
Returns:
The number of bytes in the data portion of the ICMP ping request packet.

getRequestPacketLength

public int getRequestPacketLength()
Returns:
The number of bytes in the entire IP ping request packet.

Savarese.Org

Copyright © 2004-2007 Daniel F. Savarese. All Rights Reserved.