How to make the program impatient?

    The programs that were written in previous lectures of the course “Network Programming in UNIX” had an endless supply of patience, that is, they implicitly waited until the data for processing arrived. In a new lecture, you will learn how to limit the patience of a program to a specific time frame.

    The author of the course, Alexander Patrakov, tells how to process time-related events in a 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 little more complicated.

    In the case of non-blocking sockets, to effectively calculate the timeout value that must be passed to the select () function or its analogs, you can apply a data structure called the “binary heap”. Its other name is “pyramid”.

    To see 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. To each client according to the process
    3. We implement the protocol or how astrologers work
    4. About how to read until the end
    5. Automatic programs - translation difficulties
    6. How to do several things at the same time and at the same time in turn?
    7. Effective reading

    Also popular now: