1ICMP(4P) ICMP(4P)
2
3
4
6 icmp - Internet Control Message Protocol
7
9 #include <sys/socket.h>
10 #include <netinet/in.h>
11
12 s = socket(AF_INET, SOCK_RAW, proto);
13
15 ICMP is the error and control message protocol used by IP and the
16 Internet protocol family. It may be accessed through a “raw socket”
17 for network monitoring and diagnostic functions. The proto parameter
18 to the socket call to create an ICMP socket is obtained from getproto‐
19 byname(3N). ICMP sockets are connectionless, and are normally used
20 with the sendto and recvfrom calls, though the connect(2) call may also
21 be used to fix the destination for future packets (in which case the
22 read(2) or recv(2) and write(2) or send(2) system calls may be used).
23
24 Outgoing packets automatically have an IP header prepended to them
25 (based on the destination address). Incoming packets are received with
26 the IP header and options intact.
27
29 A socket operation may fail with one of the following errors returned:
30
31 [EISCONN] when trying to establish a connection on a socket which
32 already has one, or when trying to send a datagram with
33 the destination address specified and the socket is
34 already connected;
35
36 [ENOTCONN] when trying to send a datagram, but no destination
37 address is specified, and the socket hasn't been con‐
38 nected;
39
40 [ENOBUFS] when the system runs out of memory for an internal data
41 structure;
42
43 [EADDRNOTAVAIL]
44 when an attempt is made to create a socket with a net‐
45 work address for which no network interface exists.
46
48 send(2), recv(2), intro(4N), inet(4F), ip(4P)
49
50
51
524.3 Berkeley Distribution May 16, 1986 ICMP(4P)