new copyright notice
[unix-history] / usr / src / share / man / man4 / icmp.4
CommitLineData
f29f3a8b 1.\" Copyright (c) 1986 Regents of the University of California.
97cd0d25 2.\" All rights reserved.
f29f3a8b 3.\"
91cff1e1 4.\" %sccs.include.redist.man%
97cd0d25 5.\"
91cff1e1 6.\" @(#)icmp.4 6.5 (Berkeley) %G%
f29f3a8b 7.\"
1324d254 8.TH ICMP 4 ""
f29f3a8b
MK
9.UC 6
10.SH NAME
11icmp \- Internet Control Message Protocol
12.SH SYNOPSIS
13.B #include <sys/socket.h>
14.br
15.B #include <netinet/in.h>
16.PP
17.B s = socket(AF_INET, SOCK_RAW, proto);
18.SH DESCRIPTION
19ICMP is the error and control message protocol used
20by IP and the Internet protocol family. It may be accessed
21through a \*(lqraw socket\*(rq for network monitoring
22and diagnostic functions.
23The
24.I proto
25parameter to the socket call to create an ICMP socket
26is obtained from
1324d254 27.IR getprotobyname (3).
f29f3a8b
MK
28ICMP sockets are connectionless,
29and are normally used with the
30.I sendto
31and
32.I recvfrom
33calls, though the
34.IR connect (2)
35call may also be used to fix the destination for future
36packets (in which case the
37.IR read (2)
38or
39.IR recv (2)
40and
41.IR write (2)
42or
43.IR send (2)
44system calls may be used).
45.PP
46Outgoing packets automatically have an IP header prepended to
47them (based on the destination address).
48Incoming packets are received with the IP header and options intact.
49.SH DIAGNOSTICS
50A socket operation may fail with one of the following errors returned:
51.TP 15
52[EISCONN]
53when trying to establish a connection on a socket which
54already has one, or when trying to send a datagram with the destination
55address specified and the socket is already connected;
56.TP 15
57[ENOTCONN]
58when trying to send a datagram, but
59no destination address is specified, and the socket hasn't been
60connected;
61.TP 15
62[ENOBUFS]
63when the system runs out of memory for
64an internal data structure;
65.TP 15
66[EADDRNOTAVAIL]
67when an attempt is made to create a
68socket with a network address for which no network interface
69exists.
70.SH SEE ALSO
1324d254 71send(2), recv(2), intro(4), inet(4), ip(4)