select()
system call, receiving either three file descriptor sets (described below) including read, write and exceptional file descriptor sets, allows the user process to instruct the Kernel to wait for either reading, writing, or exceptional I/O events to happen and to wake up the process only when one of these events occur. The first argument for select()
should be the highest-numbered file descriptor (numfds
) to be tested in any of passed three sets plus 1. With this system call, we can monitor several sockets (up until the limit numfds
) via their File Descriptor# at the same time to see which one is ready for reading, which one is ready for writing etc. in a non-blocking manner. Meaning, the process will only be notified when the data is readily available for reading from either socket. An example usage of select()
is shown below: