An Important API: select() or poll()

Let's discuss how the event loop receives events in this lesson.

We'll cover the following

With that basic event loop in mind, we next must address the question of how to receive events. In most systems, a basic API is available, via either the select() or poll() system calls.

What these interfaces enable a program to do is simple: check whether there is any incoming I/O that should be attended to. For example, imagine that a network application (such as a web server) wishes to check whether any network packets have arrived, in order to service them. These system calls let you do exactly that.

select()

Take select() for example. The manual page (on a Mac) describes the API in this manner:

Get hands-on with 1200+ tech skills courses.