icmp(4p) icmp(4p)
Name
icmp - Internet Control Message Protocol
Syntax
#include <sys/socket.h>
#include <netinet/in.h>
s = socket(AF_INET, SOCK_RAW, proto);
Description
The ICMP is the error and control message protocol used by the Internet Protocol (IP) transport layer and the Internet protocol family. It
can be accessed through a ``raw socket'' for network monitoring and diagnostic functions. The proto argument to the socket call to create
an ICMP socket is obtained from the routine. ICMP sockets are connectionless, and are normally used with the and system calls. The call
can also be used to fix the destination for future packets (in which case the or and or system calls can then be used).
Outgoing packets automatically have an IP header prepended to them (based on the destination address). Incoming packets are received with
the IP header and options intact.
Diagnostics
On failure, a socket operation returns any of the following errors:
[EISCONN] Tried to establish a connection on a socket that already has one, or tried to send a datagram with the destination address
specified and the socket was already connected.
[ENOTCONN] Tried to send a datagram, but no destination address was specified, and the socket has not connected.
[ENOBUFS] The system ran out of memory for an internal data structure.
[EADDRNOTAVAIL]
An attempt was made to create a socket with a network address for which no network interface exists.
See Also
inet(4f), intro(4n), ip(4p)
icmp(4p)