xref: /csrg-svn/share/man/man4/udp.4 (revision 61599)
1*61599Sbostic.\" Copyright (c) 1983, 1991, 1993
2*61599Sbostic.\"	The Regents of the University of California.  All rights reserved.
320746Smckusick.\"
443581Strent.\" %sccs.include.redist.man%
520746Smckusick.\"
6*61599Sbostic.\"     @(#)udp.4	8.1 (Berkeley) 06/05/93
736752Sbostic.\"
847675Scael.Dd
947675Scael.Dt UDP 4
1047675Scael.Os BSD 4.2
1147675Scael.Sh NAME
1247675Scael.Nm udp
1347675Scael.Nd Internet User Datagram Protocol
1447675Scael.Sh SYNOPSIS
1547675Scael.Fd #include <sys/socket.h>
1647675Scael.Fd #include <netinet/in.h>
1747675Scael.Ft int
1847675Scael.Fn socket AF_INET SOCK_DGRAM 0
1947675Scael.Sh DESCRIPTION
2047675Scael.Tn UDP
2147675Scaelis a simple, unreliable datagram protocol which is used
2247675Scaelto support the
2347675Scael.Dv SOCK_DGRAM
2447675Scaelabstraction for the Internet
2547675Scaelprotocol family.
2647675Scael.Tn UDP
2747675Scaelsockets are connectionless, and are
2820746Smckusicknormally used with the
2947675Scael.Xr sendto
3020746Smckusickand
3147675Scael.Xr recvfrom
3220746Smckusickcalls, though the
3347675Scael.Xr connect 2
3420746Smckusickcall may also be used to fix the destination for future
3520746Smckusickpackets (in which case the
3647675Scael.Xr recv 2
3720746Smckusickor
3847675Scael.Xr read 2
3920746Smckusickand
4047675Scael.Xr send 2
4120746Smckusickor
4247675Scael.Xr write 2
4320746Smckusicksystem calls may be used).
4447675Scael.Pp
4547675Scael.Tn UDP
4647675Scaeladdress formats are identical to those used by
4747675Scael.Tn TCP .
4847675ScaelIn particular
4947675Scael.Tn UDP
5047675Scaelprovides a port identifier in addition
5147675Scaelto the normal Internet address format.  Note that the
5247675Scael.Tn UDP
5347675Scaelport
5447675Scaelspace is separate from the
5547675Scael.Tn TCP
5647675Scaelport space (i.e. a
5747675Scael.Tn UDP
5847675Scaelport
5947675Scaelmay not be
6047675Scael.Dq connected
6147675Scaelto a
6247675Scael.Tn TCP
6347675Scaelport).  In addition broadcast
6420746Smckusickpackets may be sent (assuming the underlying network supports
6547675Scaelthis) by using a reserved
6647675Scael.Dq broadcast address ;
6747675Scaelthis address
6820746Smckusickis network interface dependent.
6947675Scael.Pp
7047675ScaelOptions at the
7147675Scael.Tn IP
7247675Scaeltransport level may be used with
7347675Scael.Tn UDP ;
7447675Scaelsee
7547675Scael.Xr ip 4 .
7647675Scael.Sh DIAGNOSTICS
7720746SmckusickA socket operation may fail with one of the following errors returned:
7847675Scael.Bl -tag -width [EADDRNOTAVAIL]
7947675Scael.It Bq Er EISCONN
8020746Smckusickwhen trying to establish a connection on a socket which
8120746Smckusickalready has one, or when trying to send a datagram with the destination
8220746Smckusickaddress specified and the socket is already connected;
8347675Scael.It Bq Er ENOTCONN
8420746Smckusickwhen trying to send a datagram, but
8520746Smckusickno destination address is specified, and the socket hasn't been
8620746Smckusickconnected;
8747675Scael.It Bq Er ENOBUFS
8820746Smckusickwhen the system runs out of memory for
8920746Smckusickan internal data structure;
9047675Scael.It Bq Er EADDRINUSE
9120746Smckusickwhen an attempt
9220746Smckusickis made to create a socket with a port which has already been
9320746Smckusickallocated;
9447675Scael.It Bq Er EADDRNOTAVAIL
9520746Smckusickwhen an attempt is made to create a
9620746Smckusicksocket with a network address for which no network interface
9720746Smckusickexists.
9847675Scael.El
9947675Scael.Sh SEE ALSO
10047675Scael.Xr getsockopt 2 ,
10147675Scael.Xr recv 2 ,
10247675Scael.Xr send 2 ,
10347675Scael.Xr socket 2 ,
10447675Scael.Xr intro 4 ,
10547675Scael.Xr inet 4 ,
10647675Scael.Xr ip 4
10747675Scael.Sh HISTORY
10847675ScaelThe
10947675Scael.Nm
11047675Scaelprotocol appeared in
11147675Scael.Bx 4.2 .
112