Commit | Line | Data |
---|---|---|
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 | |
10 | udp \- 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 | |
18 | UDP is a simple, unreliable datagram protocol which is used | |
19 | to support the SOCK_DGRAM abstraction for the Internet | |
20 | protocol family. UDP sockets are connectionless, and are | |
21 | normally used with the | |
22 | .I sendto | |
23 | and | |
24 | .IR recvfrom | |
25 | calls, though the | |
26 | .IR connect (2) | |
27 | call may also be used to fix the destination for future | |
28 | packets (in which case the | |
29 | .IR recv (2) | |
30 | or | |
31 | .IR read (2) | |
32 | and | |
33 | .IR send (2) | |
34 | or | |
35 | .IR write(2) | |
36 | system calls may be used). | |
37 | .PP | |
38 | UDP address formats are identical to those used by | |
39 | TCP. In particular UDP provides a port identifier in addition | |
40 | to the normal Internet address format. Note that the UDP port | |
41 | space is separate from the TCP port space (i.e. a UDP port | |
42 | may not be \*(lqconnected\*(rq to a TCP port). In addition broadcast | |
43 | packets may be sent (assuming the underlying network supports | |
44 | this) by using a reserved \*(lqbroadcast address\*(rq; this address | |
45 | is network interface dependent. | |
46 | .SH DIAGNOSTICS | |
47 | A socket operation may fail with one of the following errors returned: | |
48 | .TP 15 | |
49 | [EISCONN] | |
50 | when trying to establish a connection on a socket which | |
51 | already has one, or when trying to send a datagram with the destination | |
52 | address specified and the socket is already connected; | |
53 | .TP 15 | |
54 | [ENOTCONN] | |
55 | when trying to send a datagram, but | |
56 | no destination address is specified, and the socket hasn't been | |
57 | connected; | |
58 | .TP 15 | |
59 | [ENOBUFS] | |
60 | when the system runs out of memory for | |
61 | an internal data structure; | |
62 | .TP 15 | |
63 | [EADDRINUSE] | |
64 | when an attempt | |
65 | is made to create a socket with a port which has already been | |
66 | allocated; | |
67 | .TP 15 | |
68 | [EADDRNOTAVAIL] | |
69 | when an attempt is made to create a | |
70 | socket with a network address for which no network interface | |
71 | exists. | |
72 | .SH SEE ALSO | |
73 | send(2), | |
74 | recv(2), | |
75 | intro(4N), | |
76 | inet(4F) |