|
|
Datagram sockets are created and name bound exactly as are stream
sockets but to send data from a datagram socket,
the process uses the sendto primitive:
sendto(s, buf, buflen, flags, &to, tolen);
The parameters are the same as those described for send, except the to and tolen values are used to indicate the intended recipient of the message.
When using an unreliable datagram interface, it is unlikely any errors will be reported to the sender. If information at the sending node indicates that the message cannot be delivered, the call returns -1, and the global variable errno contains an error number.