select(NULL,NULL,NULL和&timeout)只是等待给定的时间吗?(Does select(NULL, NULL, NULL, &timeout) just wait the giv

编程入门 行业动态 更新时间:2024-10-28 13:28:03
select(NULL,NULL,NULL和&timeout)只是等待给定的时间吗?(Does select(NULL, NULL, NULL, &timeout) just wait the given time?)

给定代码中出现了以下行:

select(0, (fd_set *) NULL, (fd_set *) NULL, (fd_set *) NULL, &timeout);

http://linux.die.net/man/2/select

如果不对相应的事件类别观察文件描述符,则可以将三个文件描述符集合中的每一个指定为NULL。

所以我可以看到将NULL传递给它是有效的。 在这种情况下,它只能导致积极等待。

它是否正确? 我有点不确定..

the following line has come to my eyes in given code:

select(0, (fd_set *) NULL, (fd_set *) NULL, (fd_set *) NULL, &timeout);

http://linux.die.net/man/2/select

Each of the three file descriptor sets may be specified as NULL if no file descriptors are to be watched for the corresponding class of events.

So I can see that it is valid to pass NULL into it. In that case it can only lead to do active waiting.

Is this correct? I am a bit unsure..

最满意答案

有些代码调用select(),其中所有三个组都为空,nfds为零,非NULL超时作为一种相当便携的方式以亚秒级精度进行休眠。

从这里开始 。

Some code calls select() with all three sets empty, nfds zero, and a non-NULL timeout as a fairly portable way to sleep with subsecond precision.

Taken from here.

更多推荐

本文发布于:2023-07-04 10:06:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1023032.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:时间   NULL   select   timeout   time

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!