Reputation: 416
I'm trying to understand the "events" pointer in epoll_wait. When epoll_wait returns, does this pointer point to some memory (not allocated by the user) where all the events structures are present? Or do we have to allocate memory to this pointer and then pass the pointer so that the events will get filled up in that memory location?
If memory has to be allocated, then how much should be allocated? Let's say I want to do an epoll_wait on 10,000 sockets. All of them are to be checked for data to be read (EPOLLIIN). So, should I allocate memory equivalent to 10,000 event structures to *events?
Thanks,
VSN
Upvotes: 0
Views: 583
Reputation: 41
MaxEvents is how big your array is in elements. If you allocate memory that is sizeof(epoll_event) * 10
, then maxEvents
is 10. MaxEvents is unrelated to the number of sockets you are listening on.
Upvotes: 1
Reputation: 409482
Have you looked at the example in e.g. the epoll(7) manual page? You need to provide the actual event array, either as a proper array as in the example, or by allocating of the heap (and freeing it later).
Upvotes: 1