免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4799 | 回复: 8
打印 上一主题 下一主题

[C] 为什么select没有阻塞? [复制链接]

论坛徽章:
0
1 [报告]
发表于 2008-10-06 21:02 |只看该作者

回复 #1 wsgtrsys 的帖子

没有阻塞那么select返回什么了呢?
有没有出错,如果出错检查一下errno呢?

论坛徽章:
0
2 [报告]
发表于 2008-10-06 21:05 |只看该作者
select为实现非阻塞IO操作而设计。
  select() and  pselect()  allow  a  program  to  monitor  multiple  file
       descriptors,  waiting  until one or more of the file descriptors become
       "ready" for some class of I/O operation (e.g., input possible).  A file
       descriptor  is considered ready if it is possible to perform the corre-
       sponding I/O operation (e.g., read(2)) without blocking.

论坛徽章:
0
3 [报告]
发表于 2008-10-06 21:13 |只看该作者

回复 #3 x2 的帖子

......
select() and  pselect()  allow  a  program  to  monitor  multiple  file descriptors,  waiting  until one or more of the file descriptors become "ready" for some class of I/O operation (e.g., input possible).  A file descriptor is considered ready if it is possible to perform the corresponding I/O operation (e.g., read(2)) without blocking.

看manual稍微认真点萨,实现synchronous I/O总有可能阻塞啊

论坛徽章:
1
申猴
日期:2014-02-11 14:50:31
4 [报告]
发表于 2008-10-06 22:52 |只看该作者
client close了?

论坛徽章:
1
处女座
日期:2013-08-19 12:39:10
5 [报告]
发表于 2008-10-06 23:03 |只看该作者
原帖由 chenzhanyiczy 于 2008-10-6 22:52 发表
client close了?

没错.找到问题了

论坛徽章:
0
6 [报告]
发表于 2008-10-06 23:15 |只看该作者
select 函数是实现多路复用时用的。
对文件描述符都可以复用,所以可以监听本地文件或网络socket。
select就是非阻塞的,在使用的时候需要对他的返回值作判断,根据
返回值得情况来确定程序的流程。

论坛徽章:
0
7 [报告]
发表于 2008-10-07 10:12 |只看该作者
感觉还是client推出了

论坛徽章:
0
8 [报告]
发表于 2008-10-07 10:27 |只看该作者
原帖由 x2 于 2008-10-6 21:05 发表
select为实现非阻塞IO操作而设计。



头一次听说。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP