.\" This man page is Copyright (C) 1999 Andi Kleen <ak@muc.de>.
+.\"
+.\" %%%LICENSE_START(VERBATIM_ONE_PARA)
.\" Permission is granted to distribute possibly modified copies
.\" of this page provided the header is included verbatim,
.\" and in case of nontrivial modification author and date
.\" of the modification is added to the header.
+.\" %%%LICENSE_END
+.\"
.\" $Id: udp.7,v 1.7 2000/01/22 01:55:05 freitag Exp $
.\"
-.TH UDP 7 2010-06-13 "Linux" "Linux Programmer's Manual"
+.TH UDP 7 2013-07-31 "Linux" "Linux Programmer's Manual"
.SH NAME
udp \- User Datagram Protocol for IPv4
.SH SYNOPSIS
.B #include <sys/socket.h>
.br
.B #include <netinet/in.h>
+.br
+.B #include <netinet/udp.h>
.sp
.B udp_socket = socket(AF_INET, SOCK_DGRAM, 0);
.SH DESCRIPTION
In order to receive packets, the socket can be bound to a local
address first by using
.BR bind (2).
-Otherwise the socket layer will automatically assign
+Otherwise, the socket layer will automatically assign
a free local port out of the range defined by
.I /proc/sys/net/ipv4/ip_local_port_range
and bind the socket to
IP options may be sent or received using the socket options described in
.BR ip (7).
-They are only processed by the kernel when the appropriate
+They are processed by the kernel only when the appropriate
.I /proc
parameter
is enabled (but still passed to the user even when it is turned off).
When the
.B MSG_DONTROUTE
flag is set on sending, the destination address must refer to a local
-interface address and the packet is only sent to that interface.
+interface address and the packet is sent only to that interface.
By default, Linux UDP does path MTU (Maximum Transmission Unit) discovery.
This means the kernel
that exceed the interface MTU.
However, disabling it is not recommended
for performance and reliability reasons.
-.SS "Address Format"
+.SS Address format
UDP uses the IPv4
.I sockaddr_in
address format described in
.BR ip (7).
-.SS "Error Handling"
+.SS Error handling
All fatal errors will be passed to the user as an error return even
when the socket is not connected.
This includes asynchronous errors
even if total pages of UDP sockets exceed
.I udp_mem
pressure.
-.SS "Socket Options"
+.SS Socket options
To set or get a UDP socket option, call
.BR getsockopt (2)
to read or
.BR setsockopt (2)
to write the option with the option level argument set to
.BR IPPROTO_UDP .
+Unless otherwise noted,
+.I optval
+is a pointer to an
+.IR int .
.TP
.BR UDP_CORK " (since Linux 2.5.44)"
If this option is enabled, then all data output on this socket
Returns the number of data bytes in the local send queue.
Only supported with Linux 2.4 and above.
.PP
-In addition all ioctls documented in
+In addition, all ioctls documented in
.BR ip (7)
and
.BR socket (7)
is a new feature in Linux 2.2.
.\" .SH CREDITS
.\" This man page was written by Andi Kleen.
-.SH "SEE ALSO"
+.SH SEE ALSO
.BR ip (7),
.BR raw (7),
.BR socket (7),
RFC\ 1122 for the host requirements.
.br
RFC\ 1191 for a description of path MTU discovery.
+.SH COLOPHON
+This page is part of release 3.79 of the Linux
+.I man-pages
+project.
+A description of the project,
+information about reporting bugs,
+and the latest version of this page,
+can be found at
+\%http://www.kernel.org/doc/man\-pages/.