manual page distributed with 4.2BSD
[unix-history] / usr / src / share / man / man4 / udp.4
CommitLineData
c82418af
KM
1.\" Copyright (c) 1983 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
46fc527a 5.\" @(#)udp.4 6.1 (Berkeley) %G%
c82418af 6.\"
46fc527a 7.TH UDP 4P ""
c82418af
KM
8.UC 5
9.SH NAME
10udp \- Internet User Datagram Protocol
11.SH SYNOPSIS
12.B #include <sys/socket.h>
13.br
14.B #include <netinet/in.h>
15.PP
16.B s = socket(AF_INET, SOCK_DGRAM, 0);
17.SH DESCRIPTION
18UDP is a simple, unreliable datagram protocol which is used
19to support the SOCK_DGRAM abstraction for the Internet
20protocol family. UDP sockets are connectionless, and are
21normally used with the
22.I sendto
23and
24.IR recvfrom
25calls, though the
26.IR connect (2)
27call may also be used to fix the destination for future
28packets (in which case the
29.IR recv (2)
30or
31.IR read (2)
32and
33.IR send (2)
34or
35.IR write(2)
36system calls may be used).
37.PP
38UDP address formats are identical to those used by
39TCP. In particular UDP provides a port identifier in addition
40to the normal Internet address format. Note that the UDP port
41space is separate from the TCP port space (i.e. a UDP port
42may not be \*(lqconnected\*(rq to a TCP port). In addition broadcast
43packets may be sent (assuming the underlying network supports
44this) by using a reserved \*(lqbroadcast address\*(rq; this address
45is network interface dependent.
46.SH DIAGNOSTICS
47A socket operation may fail with one of the following errors returned:
48.TP 15
49[EISCONN]
50when trying to establish a connection on a socket which
51already has one, or when trying to send a datagram with the destination
52address specified and the socket is already connected;
53.TP 15
54[ENOTCONN]
55when trying to send a datagram, but
56no destination address is specified, and the socket hasn't been
57connected;
58.TP 15
59[ENOBUFS]
60when the system runs out of memory for
61an internal data structure;
62.TP 15
63[EADDRINUSE]
64when an attempt
65is made to create a socket with a port which has already been
66allocated;
67.TP 15
68[EADDRNOTAVAIL]
69when an attempt is made to create a
70socket with a network address for which no network interface
71exists.
72.SH SEE ALSO
73send(2),
74recv(2),
75intro(4N),
76inet(4F)