I use epoll to record a media server. Fds are set to non-block, and I use edge related events. I know that for EPOLLIN I need to loop read fd until EAGAIN is returned. But what about spelling?
When I want to write, I queue the data and set EPOLLOUT | EPOLLIN | EPOLLET on fd. When the EPOLLOUT event occurs, I write the entire buffer in the queue with one shot:
n = send ( fd, buf, buf_len, MSG_NOSIGNAL );
If n> 0 && n <buf_len I just reset EPOLLOUT and return. I see no reason to get hung up on sending (which, I think, implies a man page for epoll). Looks like send indicated that it had just taken everything it could and would return EAGAIN if called immediately.
Excludes a system call here is the most efficient route?
source share