for the same socket, I want to register two events: one is EPOLLIN and another is EPOLLOUT|EPOLLET.
so for input, I want it to be level trigger and for output I want it to be edge trigger.
ev.data.fd=fd;
ev.events=EPOLLIN;
epoll_ctl(epfd,EPOLL_CTL_ADD,fd,&ev);
ev.events=EPOLLOUT|EPOLLET;
epoll_ctl(epfd,EPOLL_CTL_ADD,fd,&ev);
is it possible or not? are there any problems? thanks!
Here's from epoll(7) Questions and answers section:
Q1What happens if you register the same file descriptor on anepollinstance twice?
A1You will probably getEEXIST. However, it is possible to add a duplicate (dup(2),dup2(2),fcntl(2)F_DUPFD) descriptor to the sameepoll instance. This can be a useful technique for filtering events, if the duplicate file descriptors are registered with differenteventsmasks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With