]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man7/udp.7
getent.1, intro.1, time.1, _exit.2, _syscall.2, accept.2, access.2, acct.2, adjtimex...
[thirdparty/man-pages.git] / man7 / udp.7
CommitLineData
77117f4f
MK
1.\" This man page is Copyright (C) 1999 Andi Kleen <ak@muc.de>.
2.\" Permission is granted to distribute possibly modified copies
3.\" of this page provided the header is included verbatim,
4.\" and in case of nontrivial modification author and date
5.\" of the modification is added to the header.
6.\" $Id: udp.7,v 1.7 2000/01/22 01:55:05 freitag Exp $
7.\"
402ffae3 8.TH UDP 7 2010-06-13 "Linux" "Linux Programmer's Manual"
77117f4f
MK
9.SH NAME
10udp \- User Datagram Protocol for IPv4
11.SH SYNOPSIS
12.B #include <sys/socket.h>
13.br
14.B #include <netinet/in.h>
15.sp
d4c8c97c 16.B udp_socket = socket(AF_INET, SOCK_DGRAM, 0);
77117f4f
MK
17.SH DESCRIPTION
18This is an implementation of the User Datagram Protocol
19described in RFC\ 768.
20It implements a connectionless, unreliable datagram packet service.
21Packets may be reordered or duplicated before they arrive.
22UDP generates and checks checksums to catch transmission errors.
23
24When a UDP socket is created,
25its local and remote addresses are unspecified.
26Datagrams can be sent immediately using
27.BR sendto (2)
28or
29.BR sendmsg (2)
30with a valid destination address as an argument.
31When
32.BR connect (2)
fe10db36 33is called on the socket, the default destination address is set and
77117f4f
MK
34datagrams can now be sent using
35.BR send (2)
36or
37.BR write (2)
38without specifying a destination address.
39It is still possible to send to other destinations by passing an
40address to
41.BR sendto (2)
42or
43.BR sendmsg (2).
fe10db36 44In order to receive packets, the socket can be bound to a local
77117f4f
MK
45address first by using
46.BR bind (2).
47Otherwise the socket layer will automatically assign
48a free local port out of the range defined by