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
引用unp解释socket在什么情况下可读?
最新推荐文章于 2021-10-14 13:59:45 发布