Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use epoll with data->ptr, instead of data.fd?

Tags:

epoll

I'm writing an application using epoll and large amount of fd's. in order to improve the searches of fd to application relevant DB, I want to pass to epoll application info, such as index in DB array. I thought of using the data->ptr (epoll_data_t --> *ptr), as far as I understood, I can give pointer that holds the fd and private information from the application layer, but couldn't found any documents or examples.

I found this post, which seems to be relevant, but there is no implementation example... How to use epoll_event data.ptr

Thanks

like image 681
user1927740 Avatar asked Dec 15 '22 15:12

user1927740


1 Answers

You can put whatever you want in data. It's not used by epoll itself, it just returns it when the event occurs on the fd specified in the argument list.

like image 58
Barmar Avatar answered Mar 05 '23 14:03

Barmar