Constructs a new socket that is able to send and receive ICMP messages.
The newly constructed socket will receive all ICMP messages directed at
the local machine. The application must be prepared to handle any and
discard any non-interesting ICMP messages.
IOException - This exception is thrown if the socket fails to be opened
public final void setTrafficClass(int tc)
This method is used to set the traffic class for the socket. (Essentially,
the QoS flags for the packets sent through this socket.) This is equivalent
to Java's Socket.setTrafficClass(int).
This method is used to receive the next ICMP datagram from the operating
system. The returned datagram packet's address is set to the sending
host's address. The port number is always set to Zero, and the buffer is
set to the contents of the raw ICMP message.
IOException - Thrown if an error occurs reading the next ICMP message.
This method is used to send the passed datagram using the ICMP transport.
The destination of the datagram packet is used as the send to destination
for the underlying ICMP socket. The port number of the datagram packet is
IOException - Thrown if an error occurs sending the datagram to the
This method is used to close and release the resources associated with the
instance. The file descriptor is closed at the operating system level and
any subsequent calls to this instance should result in exceptions being