System Interface Guide

Datagram sockets

A datagram socket does not require that a connection be established. Each message carries the destination address. If a particular local address is needed, a call to bind(3N) must precede any data transfer. Data is sent through calls to sendto(3N) or sendmsg(3N) (see send(3N)). The sendto(3N) call is like a send(3N) call with the destination address also specified.

To receive datagram socket messages, call recvfrom(3N)or recvmsg(3N) (see recv(3N)). While recv(3N) requires one buffer for the arriving data, recvfrom(3N) requires two buffers, one for the incoming message and another to receive the source address.

Datagram sockets can also use connect(3N) to connect the socket to a specified destination socket. When this is done, send(3N) and recv(3N) are used to send and receive data.

accept(3N) and listen(3N) are not used with datagram sockets.