1UDP(4P)                                                                UDP(4P)
2
3
4

NAME

6       udp - Internet User Datagram Protocol
7

SYNOPSIS

9       #include <sys/socket.h>
10       #include <netinet/in.h>
11
12       s = socket(AF_INET, SOCK_DGRAM, 0);
13

DESCRIPTION

15       UDP  is a simple, unreliable datagram protocol which is used to support
16       the SOCK_DGRAM abstraction for the Internet protocol family.  UDP sock‐
17       ets  are  connectionless,  and  are  normally  used with the sendto and
18       recvfrom calls, though the connect(2) call may also be used to fix  the
19       destination  for  future  packets (in which case the recv(2) or read(2)
20       and send(2) or write(2) system calls may be used).
21
22       UDP address formats are identical to those used by TCP.  In  particular
23       UDP  provides  a  port  identifier  in  addition to the normal Internet
24       address format.  Note that the UDP port space is separate from the  TCP
25       port  space (i.e. a UDP port may not be “connected” to a TCP port).  In
26       addition broadcast packets may be sent (assuming the underlying network
27       supports this) by using a reserved “broadcast address”; this address is
28       network interface dependent.
29
30       Options at the IP transport level may be used with UDP; see ip(4P).
31

DIAGNOSTICS

33       A socket operation may fail with one of the following errors returned:
34
35       [EISCONN]      when trying to establish a connection on a socket  which
36                      already  has one, or when trying to send a datagram with
37                      the destination address  specified  and  the  socket  is
38                      already connected;
39
40       [ENOTCONN]     when  trying  to  send  a  datagram,  but no destination
41                      address is specified, and the socket  hasn't  been  con‐
42                      nected;
43
44       [ENOBUFS]      when  the system runs out of memory for an internal data
45                      structure;
46
47       [EADDRINUSE]   when an attempt is made to create a socket with  a  port
48                      which has already been allocated;
49
50       [EADDRNOTAVAIL]
51                      when  an  attempt is made to create a socket with a net‐
52                      work address for which no network interface exists.
53

SEE ALSO

55       getsockopt(2), recv(2), send(2), socket(2), intro(4N), inet(4F), ip(4P)
56
57
58
594.2 Berkeley Distribution        May 16, 1986                          UDP(4P)
Impressum