int select(int nfds,
fd_set *readfds,
fd_set *writefds,
fd_set *exceptfds,
struct timeval *timeout);
The first parameter of select, nfds, is supposed to be the maximum file descriptor plus 1, which should be at least 1.
But I have seen some codes set nfds to be 0, is this usage legal?
Plus, the return value of select is set to EINVAL when nfds is negative or timeout contains invalid value. Again, it does not specify what happened when nfds is 0.
It is possible to use select as an alternative for sleep. I believe it is achieved by specyfying all parameters as 0/NULL except timeout. Consult
Why use select() instead of sleep()?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With