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