📜 ⬆️ ⬇️

How to make the program impatient?



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”.

To learn how it works, watch the video.



Slides are available here.

Previous lectures:
1. A course for those who are not afraid of UNIX and C
2. Each client in the process
3. Implement the protocol or how astrologers work
4. How to read to the end
5. Automata-style programs - translation difficulties
6. How to do several things at the same time and at the same time in turn?
7. Effective reading

Source: https://habr.com/ru/post/145883/


All Articles