今天用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

最新文章

  1. eclipse常用配置
  2. imageNamed、imageWithContentsOfFile、imageWithData
  3. HDU 1069---背包---Monkey and Banana
  4. 深入理解MYSQL的MDL元数据锁
  5. SQL Server 2008 远程过程调用失败
  6. Hibernate解决高并发问题之:悲观锁 VS 乐观锁
  7. [网络]_[0基础]_[使用putty备份远程数据]
  8. Docker镜像构建的两种方式
  9. ThreeJS的特效合成器和后期处理通道
  10. Java面试总结(二)
  11. 随机逻辑回归random logistic regression-特征筛选
  12. telnet限制用户连接数(CentOS)
  13. 微信小程序获取用户信息
  14. [mBean]-Delphi框架,回归简单,自然。
  15. js之获取url中"?"后面的字串
  16. cjson库
  17. 接口测试工具Soapui5.1.2参数化之Properties20150924
  18. Codeforces Round #474-E(树形dp)
  19. 43.国际化-app级别的资源文件
  20. arm平台的调用栈回溯(backtrace)

热门文章

  1. Hadoop伪分布式模式搭建
  2. 数据结构之链式队列(C实现)
  3. 【洛谷3239_BZOJ4008】[HNOI2015] 亚瑟王(期望 DP)
  4. 石墨烯(转自wiki)
  5. 365 Water and Jug Problem 水壶问题
  6. [译]HTTP POSTing
  7. [书目20140824]触动人心:设计优秀的iPhone应用
  8. Spring Boot (31) 数据验证
  9. 前端--3、JavaScript
  10. Debug技巧(1)