Epoll in Epollin and Epollout

Source: Internet
Author: User

Epoll is mainly the event callback run, we use the socket when the main use of two events

Epollout Event:
The Epollout event is only triggered once when connected, indicates writable, and other times you want to trigger, then you need to prepare the following conditions:
1. A write, full of send buffer, return error code eagain.
2. The peer read some data, and re-writable, this will trigger epollout.
Simply put: The Epollout event is only triggered once when it is not writable to a writable change, so it is called the Edge trigger, which is the right word!

In fact, if you really want to force the trigger once, there is a way to call Epoll_ctl to reset the event, the event is identical to the original settings (but must contain epollout), the key is to reset, The Epollout event is triggered immediately.

From the perspective of the application, this event is the local side state changed.

Epollin Event:
The Epollin event is triggered only when there is data written to the end, so it is necessary to continuously read all data until the Eagain is read. Otherwise, the rest of the data can only be taken out together at the next peer-to-peer write.
Now understand why Epoll must ask for an asynchronous socket? If you synchronize the socket and require reading all the data, you will end up plugging in the block.

From the application, this event is used to read the data.

Epoll in Epollin and Epollout

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.