Eagain meaning in "Go" Linux

Source: Internet
Author: User

In Linux, development often encounters many errors (setting errno), where Eagain is one of the more common errors (for example, in non-blocking operations).
Literally, it is a hint to try again. This error often occurs when the application is doing some non-blocking (non-blocking) operations (for files or sockets). For example, open the file/socket/fifo with the O_nonblock flag, and if you do a continuous read operation without data readability, the program will not block up and wait for the data to be ready to return, and the Read function will return an error Eagain Tip Your app now has no data to read please try again later.
For example, when a system call (such as fork) fails because there is not enough resources (such as virtual memory), the return eagain prompts it to be called again (perhaps next time it succeeds).


linux-non-blocking socket programming processing Eagain error
What does it mean when a non-blocking socket on Linux receives data that often appears resource temporarily Unavailable,errno code (eagain)?
This indicates that you have a blocking operation in non-blocking mode, and return this error if the operation is not completed, which will not break the socket synchronization, do not control it, and the next loop will be recv. For non-blocking sockets, Eagain is not an error. On VxWorks and Windows, Eagain is named Ewouldblock.
In addition, if EINTR is present, errno is 4, error description interrupted system call, the operation should continue.
Finally, if the return value of recv is 0, it indicates that the connection has been broken and our receive operation should end.

Ireadsizeonce=read (iopencom,rxbuf+ireadsize,1024x768); if (ireadsizeonce! = ZERO)    {if (ireadsizeonce! = Eagain            ) {continue;    }     Else {    //stccomapilog.logerror ("Read serial operation Error");       return (Fun_error);}    }

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.