Question

Let's say I epoll_create1() and only interest in EPOLLIN | EPOLLET for 1 socket.

Is it possible that I will get epoll_wait() > 1 (assuming timeout=-1) for that socket and the event is EPOLLIN?

Or will epoll_wait() return 1 even there are multiple packets (let's say spread over few sec that I pause the program on purpose in the epoll_wait loop)?

Thanks in advance.

Was it helpful?

Solution

epoll_wait returns the number of events, which according to the documentation equals the "number of file descriptors ready for I/O". So you cannot get more events than the number of file descriptors you have registered.

OTHER TIPS

According to these docs for epoll_wait it should return the number of fd's that are "ready". If you only pass in one fd, then you should not get more than 1 back - that would certainly be a bug in the epoll_wait implementation, and it's been around for a while, so I expect it's fairly well tested (unless you are working on a completely new architecture or a beta-version of a C library or some such).

Also, timeout = 0, not -1.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top