Summary
The UDP protocol is a connectionless, unreliable protocol most suitable for brief, stateless interactions.
A UDP client program creates a UDP socket using socket(), sends messages to the remote host using send(), and receives incoming messages with recv(). A UDP server creates a socket using socket(), assigns it to a prearranged port using bind(), awaits incoming requests using recv(), and sends out responses with send().
Because of UDP's unreliability, messages can be lost, and naively written clients, such as those that call send() and recv() in a rigid loop, will hang while waiting for the reply to a message that was never received. One way to handle this problem is with timeouts, but this introduces problems with duplicate responses. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access