Question

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!

Was it helpful?

Solution

Here's from epoll(7) Questions and answers section:

Q1 What happens if you register the same file descriptor on an epoll instance twice?

A1 You will probably get EEXIST. However, it is possible to add a duplicate (dup(2), dup2(2), fcntl(2) F_DUPFD) descriptor to the same epoll instance. This can be a useful technique for filtering events, if the duplicate file descriptors are registered with different events masks.

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