will be helpful for those in need When an FD becomes read or write ready, you might not necessarily want to read (or write) all the data immediately. Level-triggered epoll will keep nagging you as long as the FD remains ready, whereas edge-triggered won't bother you again until the next time you get an EAGAIN (so it's more complicated to code around, but can be more efficient depending on what you need to do).
will be helpful for those in need As long as you read until you get an EAGAIN error, you will get the event the next time you are calling epoll_wait. The event is only triggered when there is a change between empty and non-empty (or full and non-full for EPOLLOUT), but that status then remains until the event is delivered via epoll_wait.
wish of those help This will indeed work, epoll acts as if all events which happened to the epoll group before you made the epoll_wait call happened the moment you make the call. epoll is designed to be used this way so do not worry about this kind of usage. As long as you handle all of the events which had been triggered at the time epoll_wait returns you need not worry about any which happens between calls to it, they will be caught next time you call it. Basically: Your usage is fine, keep going :)
I hope this helps you . Yes, you should loop until EAGAIN=EWOULDBLOCK occurs. You MUST set O_NONBLOCK on this socket descriptor in order to acheive that. You can not receive partial UDP packet. You may return to event loop and receive from that socket next time when you want, but note that kernel may not wake up your epol_wait when packets received on socket, that was not end with EAGAIN. While looping until EAGAIN, remember to in order to prevent reader starvation, you should save information that receiving on this FD is not complete when, say, 100 packets received. After that you should try another FD. When you decide to go back to event loop, just analyze saved information and try to receive unreceived packets. I do not understand what you try to say about sockaddr.
epoll: difference between level triggered and edge triggered when EPOLLONESHOT specified
wish help you to fix your issue I think the bottom line answer is "there is not difference". Looking at the code, it seems that the fd remembers the last set bits before being disabled by the one-shot. It remembers it was one shot, and it remembers whether it was ET or not.