The meaning of Eagain in Linux

Source: Internet
Author: User

First of all, I set the socket to asynchronous, and then when I use write to send data, the way is to loop a large amount of data, because it is asynchronous, Write\send will send the data submitted to the send buffer is immediately returned, do not need to confirm the data received. In this case, it is quite possible that the send buffer is filled up, causing the write\send to no longer commit the data to be sent to the buffer. So there is the resource temporarily unavailable error, Eagain meaning is also obvious, is to you try again.

     literally, it's 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, if you do a sequential read operation and no data is readable. At this point the program does not block up and waits for the data to be ready to return, and the Read function returns an error eagain, prompting your application to now have 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 when the Linux non-blocking socket receive data often appear resource temporarily Unavailable,errno code for one (Eagain), what does this mean? This indicates that you have a blocking operation in non-blocking mode, which returns the error if the operation is not completed, which does not break the synchronization of the socket, regardless of the next loop and then recv. For non-blocking sockets, Eagain is not an error.  On VxWorks and Windows, Eagain is named Ewouldblock.  Additionally, if EINTR is present as errno 4, the error description interrupted system call, the operation should also continue. Finally, if the return value of recv is 0, it indicates that the connection has been disconnected 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.