由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Linux版 - linux select(): can file descriptors be dynamtic ? (转载)
相关主题
请问mpirun怎么放在后台运行?安装unbutu10.04后导致网卡在win7和unbutu下都不能用
[请教]文件输入 (转载)是主板要坏了吗?
python descriptor 问题unplug the network cable, ifconfig still says up
100伪币答谢Linux/Unix编程问题求助:Dockstar/Goflex Net 安装Debian后的启动问题!
问个shell重定向输出的问题is this legal: can still ping eth1 through eth0, even if eth1 cable is unplugged
有没有什么办法修改另一个进程创建的socket的options你们有人用googledoc么
linux下如何量产flash drive?! chipgenius的替代品如何terminate掉一个remote server上的tcp session?
请教个简单命令问题问个TCP有关timeout的技术问题
相关话题的讨论汇总
话题: fd话题: select话题: set话题: input
进入Linux版参与讨论
1 (共1页)
w*s
发帖数: 7227
1
【 以下文字转载自 Programming 讨论区 】
发信人: wds (心开运就通,运通福就来), 信区: Programming
标 题: linux select(): can file descriptors be dynamtic ?
发信站: BBS 未名空间站 (Fri Nov 8 10:25:12 2013, 美东)
ok if i start with this, trying to read from 3 usb ports,
/* Initialize the input set */
FD_ZERO(&input);
FD_SET(usb_fd_0, &input);
FD_SET(usb_fd_1, &input);
FD_SET(usb_fd_2, &input);
max_fd = 4;
/* Initialize the timeout structure */
timeout.tv_sec = 10;
timeout.tv_usec = 0;
/* Do the select */
n = select(max_fd, &input, NULL, NULL, &timeout);
Now i unplug usb cable so usb_fd_2 is actually gone.
How to tell select to just listen on the 1st 2 ports ?
Regards !
a9
发帖数: 21638
2
这个FD_SET貌似是需要在循环里每次重新设置一次的吧?

【在 w*s 的大作中提到】
: 【 以下文字转载自 Programming 讨论区 】
: 发信人: wds (心开运就通,运通福就来), 信区: Programming
: 标 题: linux select(): can file descriptors be dynamtic ?
: 发信站: BBS 未名空间站 (Fri Nov 8 10:25:12 2013, 美东)
: ok if i start with this, trying to read from 3 usb ports,
: /* Initialize the input set */
: FD_ZERO(&input);
: FD_SET(usb_fd_0, &input);
: FD_SET(usb_fd_1, &input);
: FD_SET(usb_fd_2, &input);

w*s
发帖数: 7227
3
wow, never knew that

【在 a9 的大作中提到】
: 这个FD_SET貌似是需要在循环里每次重新设置一次的吧?
S*A
发帖数: 7142
4
那个 input array 没有没有改就不需要从新设置。
你当然可以每轮 select 之前重新设不同的值。

【在 w*s 的大作中提到】
: wow, never knew that
a9
发帖数: 21638
5
去看一下programming版thrust的回复。
我记得不重设是不行的。可能FD_ISSET会得到不可预期的结果。

【在 S*A 的大作中提到】
: 那个 input array 没有没有改就不需要从新设置。
: 你当然可以每轮 select 之前重新设不同的值。

S*A
发帖数: 7142
6
哦对,在这里,
On exit, the sets are modified in place to indicate which file descriptors
actually changed status.
关键是 select 返回后 set 被用来原地返回结果了。那是要重新填。
我糊涂了。

【在 a9 的大作中提到】
: 去看一下programming版thrust的回复。
: 我记得不重设是不行的。可能FD_ISSET会得到不可预期的结果。

1 (共1页)
进入Linux版参与讨论
相关主题
问个TCP有关timeout的技术问题问个shell重定向输出的问题
what is this?有没有什么办法修改另一个进程创建的socket的options
在家里,连上公司VPN则没法访问公网.,给指点一下,谢谢linux下如何量产flash drive?! chipgenius的替代品
ubuntu怎么显示启动菜单和启动过程请教个简单命令问题
请问mpirun怎么放在后台运行?安装unbutu10.04后导致网卡在win7和unbutu下都不能用
[请教]文件输入 (转载)是主板要坏了吗?
python descriptor 问题unplug the network cable, ifconfig still says up
100伪币答谢Linux/Unix编程问题求助:Dockstar/Goflex Net 安装Debian后的启动问题!
相关话题的讨论汇总
话题: fd话题: select话题: set话题: input