OpenNMS API 1.2.9

## org.opennms.protocols.icmp
Class IcmpSocket

    java.lang.Object
      org.opennms.protocols.icmp.IcmpSocket

public final class IcmpSocket
extends java.lang.Object

This class provides a bridge between the host operating system so that ICMP messages may be sent and received.

Author:
  Brian Weaver , OpenNMS

Field Summary
`private java.io.FileDescriptor` `m_rawFd` This instance is used by the native code to save and store file descriptor information about the icmp socket.

Constructor Summary
`IcmpSocket()` Constructs a new socket that is able to send and receive ICMP messages.

Method Summary
`void` `close()` This method is used to close and release the resources assocated with the instance.
`private void` `initSocket()` This method is used to open the initial operating system icmp socket.
`java.net.DatagramPacket` `receive()` This method is used to receive the next ICMP datagram from the operating system.
`void` `send(java.net.DatagramPacket packet)` This method is used to send the passed datagram using the ICMP transport.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### m_rawFd

    private java.io.FileDescriptor m_rawFd

  This instance is used by the native code to save and store file descriptor information about the icmp socket. This needs to be constructed prior to calling the init method, preferable in the constructor.

Constructor Detail

### IcmpSocket

    public IcmpSocket()
               throws java.io.IOException

  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.

Throws:
  `java.io.IOException` - This exception is thrown if the socket fails to be opened correctly.

Method Detail

### initSocket

    private void initSocket()
                     throws java.io.IOException

  This method is used to open the initial operating system icmp socket. The descriptor for the socket is stored in the member m_rawFd.

  Throws:
    `java.io.IOException` - This is thrown if an error occurs opening the ICMP socket.

### receive

    public final java.net.DatagramPacket receive()
                                          throws java.io.IOException

  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.

  Throws:
    `java.io.IOException` - Thrown if an error occurs reading the next ICMP message.

### send

    public final void send(java.net.DatagramPacket packet)
                    throws java.io.IOException

  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 ignored completely.

  Throws:
    `java.io.IOException` - Thrown if an error occurs sending the datagram to the remote host.
    `java.net.NoRouteToHostException` - Thrown if the destination address is a broadcast address.

### close

    public final void close()

  This method is used to close and release the resources assocated 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 generated.

OpenNMS API 1.2.9

Generated by ranger on May 19 2007 2335.