BSD 4_3 release
[unix-history] / usr / man / man4 / udp.4p
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.\"
95f51977 5.\" @(#)udp.4p 6.2 (Berkeley) 5/16/86
c82418af 6.\"
95f51977 7.TH UDP 4P "May 16, 1986"
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.
7787ae36
MK
46.PP
47Options at the IP transport level may be used with UDP; see
48.IR ip (4P).
c82418af
KM
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[EADDRINUSE]
67when an attempt
68is made to create a socket with a port which has already been
69allocated;
70.TP 15
71[EADDRNOTAVAIL]
72when an attempt is made to create a
73socket with a network address for which no network interface
74exists.
75.SH SEE ALSO
7787ae36 76getsockopt(2), recv(2), send(2), socket(2), intro(4N), inet(4F), ip(4P)