Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ udp(7) — Interactive 3.2r4.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

getprotoent(3I)

getsockopt(3I)

socket(3I)

intro(7N)

inet(7)

ip(7)

socket(7)

udp(7)  —  

NAME

udp − Internet User Datagram Protocol

SYNOPSIS

#include <sys/socket.h>
#include <netinet/in.h>

s = socket(AF_INET, SOCK_DGRAM, 0);

or

#include <sys/tiuser.h>
#include <sys/udp.h>
#include <netinet/in.h>

t = t_open("/dev/udp", O_RDWR);

DESCRIPTION

udp is a simple, unreliable datagram protocol that is used to support the SOCK_DGRAM abstraction in the socket environment and the T_CLTS type of transport in the TLI environment for the Internet protocol family.  Transport endpoints utilizing the udp protocol are connectionless.  udp sockets are normally used with the sendto and recvfrom calls, though the connect(3I) call may also be used to fix the destination for future packets (in which case the recv(3I) or read(2) and send(3I) or write(2) system calls may be used). udp TLI STREAMS are used with the t_sndudata(3N) and t_rcvudata(3N) calls.

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 “connected” to a TCP port.  In addition, broadcast packets may be sent (assuming the underlying network supports this) by using a reserved “broadcast address”; this address is network interface dependent. 

udp supports several options that are set with setsockopt(3I) in the socket emulation and t_optmgmt(3N) for TLI and tested with getsockopt(3I) for the socket emulation and t_optmgmt(3N) for TLI. 

The option level for the setsockopt call is the protocol number for udp, available from getprotobyname (see getprotoent(3I)). The same values are used with the TLI option management, but the options are specified as a sequence of options in the format specified in struct inetopts in:

#include <netinet/in.h>

The TLI options also support a number of the socket level options. 

The socket level options that apply to udp are SO_BROADCAST and SO_DONTROUTE, which are described in getsockopt(3I).

Options at the IP transport level may be used with udp; see ip(7).

SEE ALSO

getprotoent(3I), getsockopt(3I), socket(3I), intro(7N), inet(7), ip(7), socket(7).  Network Programmer’s Guide.

DIAGNOSTICS

A socket operation may fail with one of the following errors returned:

[EISCONN] when trying to establish a connection on a socket that already has one, or when trying to send a datagram with the destination address specified and the socket is already connected. 

[ENOTCONN] when trying to send a datagram, but no destination address is specified, and the socket has not been connected. 

[ENOBUFS] when the system runs out of memory for an internal data structure. 

[EADDRINUSE] when an attempt is made to create a socket with a port that has already been allocated. 

[EADDRNOTAVAIL] when an attempt is made to create a socket with a network address for which no network interface exists. 

A TLI operation may fail with one of the following errors returned:

[TOUTSTATE] when an operation is requested in the wrong sequence. 

[TBADOPT] when an incorrectly formatted or unimplemented option is specified. 

[TBADF] when the specified file descriptor does not refer to a transport endpoint. 

[TACCESS] when the user does not have the proper permissions for the operation requested. 

[TBADDATA] when the amount of data is not within the bounds of the transport provider. 

[TNOTSUPPORT] when the underlying transport provider does not support the requested operation. 

[TSYSERR] when a system error occurs during an ­operation. 

[TNOADDR] when the transport provider cannot assign the requested address. 

[TBADADDR] when the user attempts to use an illegal or incorrectly formatted address. 

[TNODATA] when O_NDELAY is set, but no data units are currently available from the transport provider, and the operation would normally have blocked. 

[TBADFLAG] when an invalid flag is specified in a t_optmgmt request. 

BUGS

read(2) may not be used with SOCK_DGRAM sockets due to the way STREAMS works. 

\*U  —  Version 1.0

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026