In addition to the connection-oriented communications described in the previous section, connectionless communication via the UDP protocol is also supported in the AF_INET and AF_INET6 domains.
Connectionless communication is handled via datagram sockets (SOCK_DGRAM). A datagram socket provides a symmetric interface for data exchange via datagrams. In contrast to connection-oriented communication, where the client and server communicate with each other over a fixed connection, no connection is set up for datagram transfers. Each message contains the destination address instead.
In "Creating a socket" there is a description of how datagram sockets are created. If a specific local address is required, the bind() function must be called before the first data transfer (see "Assigning a name to a socket"). Otherwise, the system assigns the local Internet address and/or port number the first time data is sent (see "Automatic address assignment by the system").