免费注册 查看新帖 |

Chinaunix

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

如果recv返回超时?返回什么内容. [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-05-21 13:06 |只看该作者 |倒序浏览
recv返回超时的话,返回值是什么呢?

论坛徽章:
0
2 [报告]
发表于 2007-05-21 15:11 |只看该作者

莫非阻塞模式的socket,没有收到数据会一直阻塞?

莫非阻塞模式的socket,没有收到数据会一直阻塞?

论坛徽章:
0
3 [报告]
发表于 2007-05-21 15:20 |只看该作者
可惜長這麼大,也搞了不少socket編程,就是沒用過這個recv。

论坛徽章:
0
4 [报告]
发表于 2007-05-21 15:22 |只看该作者

啊?怎么会.

楼上的开玩笑,我看到帖子的第一反应就是看看是不是recv拼写错误了.
汗.

论坛徽章:
0
5 [报告]
发表于 2007-05-21 15:26 |只看该作者
原帖由 wflyfox 于 2007-5-21 15:22 发表
楼上的开玩笑,我看到帖子的第一反应就是看看是不是recv拼写错误了.
汗.

我是說真的。

论坛徽章:
0
6 [报告]
发表于 2007-05-21 15:32 |只看该作者
找到答案了.
阻塞模式下可以用setsockopt设置SO_RCVTIMEO
SO_RCVTIMEO
              Sets  the  timeout  value  that specifies the maximum amount of time an input function waits until it completes. It accepts a timeval structure with the number of seconds and microseconds specifying the limit on how long to wait for an input operation to  complete. If a receive operation has blocked for this much time without receiving additional data, it shall return with apartial count or errno set to [EAGAIN] or [EWOULDBLOCK] if no data is received. The default for this option  is  zero,  which  indicates  that  a receive operation shall not time out. This option takes a timeval structure. Note that not all implementa- tions allow this option to be set.

多谢大家
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP