I/O multiplexing—select()

Because asynchronous I/O provides a more efficient way to maximize your application resources, it is recommended that you use asynchronous I/O APIs rather than the select() API. However, your specific application design may allow select() to be used.

Like asynchronous I/O, the select() function creates a common point to wait for multiple conditions at the same time. However, select() allows an application to specify sets of descriptors to see if the following conditions exist:

The descriptors that can be specified in each set can be socket descriptors, file descriptors, or any other object that is represented by a descriptor.

The select() function also allows the application to specify if it wants to wait for data to become available. The application can specify how long to wait.

Related reference
Example: Nonblocking I/O and select()