All rights reserved.
Redistribution and use in source and binary forms are permitted
provided that the above copyright notice and this paragraph are
duplicated in all such forms and that any documentation,
advertising materials, and other materials related to such
distribution and use acknowledge that the software was developed
by the University of California, Berkeley. The name of the
University may not be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
@(#)udp.4 6.3 (Berkeley) 02/14/89
s = socket(AF_INET, SOCK_DGRAM, 0);
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 space is separate from the TCP port space (i.e. a UDP port may not be \*(lqconnected\*(rq to a TCP port). In addition broadcast packets may be sent (assuming the underlying network supports this) by using a reserved \*(lqbroadcast address\*(rq; this address is network interface dependent.
Options at the IP transport level may be used with UDP; see ip (4).
15 [EISCONN] when trying to establish a connection on a socket which already has one, or when trying to send a datagram with the destination address specified and the socket is already connected;
15 [ENOTCONN] when trying to send a datagram, but no destination address is specified, and the socket hasn't been connected;
15 [ENOBUFS] when the system runs out of memory for an internal data structure;
15 [EADDRINUSE] when an attempt is made to create a socket with a port which has already been allocated;
15 [EADDRNOTAVAIL] when an attempt is made to create a socket with a network address for which no network interface exists.