阻塞套接字返回EAGAIN
今天用NDK写了一个通信程序,发现阻塞SOKCET 读写的时候返回了EAGAIN。NDK下PERROR输出为Try Again.查了半天头文件
在网上找到了原因。在此纪录。网址为http://blog.csdn.net/cleanfield/article/details/41649985
2)socket设置SO_RCVTIMEO和SO_SNDTIMEO对read/write有什么影响?看man怎么说
SO_RCVTIMEO and SO_SNDTIMEO
Specify the receiving or sending timeouts until reporting an error. The argument is a struct timeval. If an input or output function blocks for this period of time, and data has been sent or received, the return value of that function will be the amount of data transferred; if no data has been transferred and the timeout has been reached then -1 is returned witherrno set to EAGAIN or EWOULDBLOCK, or EINPROGRESS (for connect(2)) just as if the socket was specified to be nonblocking. If the timeout is set to zero (the default) then the operation will never timeout. Timeouts only have effect for system calls that perform socket I/O (e.g., read(2), recvmsg(2), send(2), sendmsg(2)); timeouts have no effect for select(2), poll(2), epoll_wait(2), and so on.
终于清晰了:SO_RCVTIMEO和SO_SNDTIMEO会导致read/write函数返回EAGAIN
另外,在确定错误过程中,同事提到O_NODELAY会导致write接口返回EAGAIN,的确,如果设置了O_NODELAY而当前不可写,那么write接口会设置errno为EAGAIN,但是write接口会返回0而不是-1.在本案中,hiredis接口中并没有设置O_NODELAY
最新文章
- eclipse常用配置
- imageNamed、imageWithContentsOfFile、imageWithData
- HDU 1069---背包---Monkey and Banana
- 深入理解MYSQL的MDL元数据锁
- SQL Server 2008 远程过程调用失败
- Hibernate解决高并发问题之:悲观锁 VS 乐观锁
- [网络]_[0基础]_[使用putty备份远程数据]
- Docker镜像构建的两种方式
- ThreeJS的特效合成器和后期处理通道
- Java面试总结(二)
- 随机逻辑回归random logistic regression-特征筛选
- telnet限制用户连接数(CentOS)
- 微信小程序获取用户信息
- [mBean]-Delphi框架,回归简单,自然。
- js之获取url中";?";后面的字串
- cjson库
- 接口测试工具Soapui5.1.2参数化之Properties20150924
- Codeforces Round #474-E(树形dp)
- 43.国际化-app级别的资源文件
- arm平台的调用栈回溯(backtrace)