Tag Archives: EAGAINResource temporarily unavailable

The meaning of eagain and resource temporarily unavailable in Linux

After the project goes online, how to reduce customers’ doubts about the delivery?Here is the secret script of three moves>>>

In Linux development, we often encounter many errors (setting errno), among which eagain is a common one (for example, in non blocking operation)
literally, it’s a prompt to try again. This error often occurs when an application performs some non blocking operation (on a file or socket). For example, take o_ The Nonblock flag opens the file/socket/FIFO, if you do read operations continuously and there is no data to read. At this time, the program will not block until the data is ready to return. The read function will return an error eagain, indicating that your application has no data to read. Please try again later
for another example, when a system call (such as fork) fails due to insufficient resources (such as virtual memory), eagain will be returned to prompt it to call again (maybe it will succeed next time)
linux – non blocking socket programming deals with eagain error
when non blocking socket receives data in Linux, resource temporarily unavailable and errno code 11 (eagain) often appears. What does this mean
this indicates that you call the blocking operation in non blocking mode and return this error before the operation is completed. This error will not destroy the synchronization of the socket. Don’t worry about it. The next cycle will be followed by recv. Eagain is not an error for non blocking sockets. On VxWorks and windows, eagain is called ewouldblock
in addition, if the Eintr, that is, errno is 4, and the error description interrupted system call occurs, the operation should continue
finally, if the return value of recv is 0, it means that the connection has been disconnected, and our receiving operation should also end
iReadSizeOnce=read(iOpenCom,RxBuf+iReadSize,1024);
if (iReadSizeOnce != ZERO)
{
if (iReadSizeOnce != EAGAIN)
{
continue;
}
else
{
// stccomapilog. Logerror (“read serial port operation error”)
return(FUN_ ERROR);
}
}