Eagain, Ewouldblock, eintr and non-blocking long connections

Source: Internet
Author: User

  Eagain, Ewouldblock, eintr with non-blocking long connections ewouldblock for non-blocking mode, no need to reread or write eintr means the operation was interrupted to wake up, You need to reread the / Writing in Linux environments 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 with the O_nonblock flag/socket/fifo, if you do a sequential read operation without data 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 handles Eagain errors often occur during Linux non-blocking socket receive data 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. 
Reprinted from: http://blog.chinaunix.net/uid-23849526-id-120552.html

Eagain, Ewouldblock, eintr and non-blocking long connections

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.