The programs that were written in previous lectures of the course “Network Programming in UNIX” had an infinite amount of patience, that is, they waited implicitly until they received data for processing. In the new lecture you will learn how to limit the program’s patience to a specific time frame.
The course author, Alexander Patrakov, describes how to handle events related to time in the network program, for example, timeouts for receiving and transmitting data. In the case of blocking sockets, everything is very simple, with non-blocking sockets - a bit more complicated. ')
In the case of non-blocking sockets, you can use a data structure called the binary heap to effectively calculate the timeout value that needs to be passed to the select () function or its analogs. Its other name is “pyramid”.