引用unp解释socket在什么情况下可读?

来源:互联网 发布:潮流的网络名词灌水 编辑:程序博客网 时间:2024/06/10 16:32

 A socket is ready for reading if any of the following four conditions is true:
a. The number of bytes of data in the socket receive buffer is greater than or
     equal to the current size of the low-water mark for the socket receive buffer.
     A read operation on the socket will not block and will return a value greater than 0
b.  The read half of the connections is closed (i.e., A TCP connection that has received a FIN).
     A read operation on the socket will not block and will return 0 (i.e., EOF)
c. The socket is a listening socket and the number of completed connection is nonzero.
    An accept on the listening socket will normally not block, although we will describe a   
d. A socket error is pending. A read operation on the socket will not block and will return
    an error (-1) with errno set to the specific error condition

原创粉丝点击