select , nfds的第一个参数应该是最大文件描述符加1,它应该至少为1。 但是我看到一些代码将nfds设置为0,这个用法是否合法? 另外,当nfds为负值或timeout值包含无效值时, select的返回值将设置为EINVAL 。 同样,它没有指定当nfds为0时发生了什么。
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.
最满意答案
可以使用select作为sleep的替代选择。 我相信它是通过将所有参数指定为0 / NULL来实现的,除了超时之外。 请教
为什么使用select()而不是sleep()?
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()?
更多推荐
发布评论