Chinaunix首页 | 论坛 | 博客
  • 博客访问: 102654
  • 博文数量: 32
  • 博客积分: 151
  • 博客等级: 入伍新兵
  • 技术积分: 225
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-11 16:18
文章分类

全部博文(32)

文章存档

2014年(27)

2013年(5)

我的朋友

分类: 网络与安全

2013-11-28 17:59:40

不一定,hp_ux下就不是。请看man recv。基本意思是设置了 O_NDELAY后,如果没数据可读也会返回0。
If the remote side of a connection-based socket has performed an
           orderly shutdown and there is no more data to read (the socket
           has reached the end of its data stream), recv() completes and
           returns 0.  The recv() call will also complete and return 0 when
           there is no data to read.  To distinguish this condition from the
           end of the data stream, you can use a select() or poll() call to
           check for data before calling recv().  If the select() or poll()
           call indicates that an event has occurred on the socket, the
           subsequent but recv() call will only return 0 if the socket has
           reached the end of the data stream.


RETURN VALUE
      recv(), recvfrom(), and recvmsg() return the following values:
 
            n   Successful completion.  n is the number of bytes received.
            0   The socket is blocking and the transport connection to the
                remote node failed, or the remote side of a connection-based
                socket has performed an orderly shutdown and there is no
                more data to read (the socket has reached the end of its
                data stream).  Sockets with the O_NDELAY flag set may also
                return 0 at any time when there is no data available.
           -1   Failure.  errno is set to indicate the error.

阅读(1770) | 评论(0) | 转发(0) |
0

上一篇:OCI编程历程(转载)

下一篇:Tomcat与Weblogic

给主人留下些什么吧!~~