UDP(7P)
NAME
udp − internet user datagram protocol
SYNOPSIS
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
s = socket(AF_INET, SOCK_DGRAM, 0);
DESCRIPTION
UDP is a simple, unreliable datagram protocol used to support the SOCK_DGRAM socket type for the internet protocol family. UDP sockets are connectionless, and are normally used with the sendto() and recvfrom() calls (see send(2) and recv(2). The connect() call can also be used to simulate a connection (see connect(2); when used in this manner, it fixes the destination for future transmitted packets (in which case the send() or write() system calls can be used), as well as designating the source from which packets are received. The recv() and read() calls can be used at any time if the source of the message is unimportant.
UDP address formats are identical to those used by TCP. In particular, UDP provides a port identifier in addition to the normal Internet address format. Note that the UDP port domain is separate from the TCP port domain (in other words, a UDP port cannot be connected to a TCP port).
The maximum message size for a UDP datagram socket is 58254 bytes. The default message size is 9216 bytes. The outbound and inbound message sizes for UDP sockets can be altered by using the SO_SNDBUF and SO_RCVBUF options of the setsockopt() system call (see getsockopt(2) for details).
DIAGNOSTICS
A socket operation may fail with one of the following errors returned in errno:
[EISCONN] Attempt to establish a connection on a socket which already has one, or attempt to send a datagram with the destination address specified, but the socket is already connected.
[ENOBUFS] The system ran out of memory for an internal data structure.
[EADDRINUSE] Attempt to create a socket with a port which has already been allocated.
[EADDRNOTAVAIL] Attempt to create a socket with a network address for which no network interface exists.
DEPENDENCIES
This entry describes the use of the UDP protocol as it applies to the Berkeley Interprocess Communication utility.
AUTHOR
udp was developed by the University of California, Berkeley.
SEE ALSO
getsockopt(2), recv(2), send(2), socket(2), inet(7F), socket(7).
NFS Services
Hewlett-Packard Company — HP-UX Release 9.03: April 1994