In Socket Communication (TCP/Blocking I/O), when reading is performed with code similar to the following,
while((c=read(fileno(din), buf, bufsize))>0){
// something to do
}
EAGAIN was mainly recognized when there was no data to read during non-blocking I/O, but
In the man below, SO_RCVTIMEO is also set during Blocking I/O, and read is
It can also be read to occur when a timeout occurs.
https://linuxjm.osdn.jp/html/LDP_man-pages/man7/socket.7.html
As mentioned above, are there any cases where EAGAIN occurs in Blocking I/O?
If so, what other cases exist besides the above?
You can assume the two cases mentioned in the question (for information on socket read
, refer to the recvmsg
documentation).There are two cases mentioned in the question)
Quoted from Error section
EAGAIN or EWOULDBLOCK
The socket is set to nonblocking and the receive operation is stopped, or the receive timeout is set to expire before receiving data.
POSIX.1-2001 allows either error to be returned in this case and does not require these two constants to have the same value.
Therefore, applications that require portability should check both possibilities.
© 2024 OneMinuteCode. All rights reserved.