Questions tagged [epollet]

Epoll in Edge Trigger mode

The epoll Linux system call has two modes of operations. The "normal" mode, called level trigger mode, will report an event if it is currently active.

In edge trigger mode, the event will only be reported once. After being reported, that same fd will not be reported for that event until all pending data is consumed.

32 questions
2
votes
2 answers

Epoll TCP edge-triggered necessity of last read(2) call

Given a nonblocking TCP socket, if the call read(sock, buf, bufLen) returns a value < bufLen, is it safe to then wait for an edge-triggered EPOLLIN event? Or must I call read again to ensure it's zero or EAGAIN? In my testing, everything stays…
Max
  • 2,760
  • 1
  • 28
  • 47
1
vote
1 answer

Question on the timing of re-arming EPOLL and related questions when using Epoll Edge Triggered

I have some questions on EPOLL when using Edge Triggered and with EPOLLONESHOT. The simplified sequence of statements are listed below. Actually multiple files are monitored by an Epoll Fd and a set is managed through a specific thread. The variable…
asinix
  • 966
  • 1
  • 9
  • 22
1
vote
1 answer

Epoll zero recv() and negative(EAGAIN) send()

I was struggling with epoll last days and I'm in the middle of nowhere right now ;) There's a lot of information on the Internet and obviously in the system man but I probably took an overdose and a bit confused. In my server app(backend to nginx)…
danilabagroff
  • 602
  • 1
  • 7
  • 23
1
vote
1 answer

What is the use case for EPOLLET?

epoll in edge trigger mode is a strange beast. It requires the process to keep track of what the last response for each monitored FD is. It mandates the process to handle, without fail, each and every event reported (or else we might think that an…
Shachar Shemesh
  • 8,193
  • 6
  • 25
  • 57
1
vote
1 answer

nonblocking socket recv problem while using it with epoll

i've got a problem: sometimes (not regularly) recv returns -1 and errno == EAGAIN while using epoll in edge-triggered mode. piece of code: server_sock = startup(&port); if ( (epollfd = epoll_create(4096)) < 0) { perror("epoll_create error"); …
milo
  • 1,220
  • 3
  • 17
  • 33
1
vote
2 answers

Multithreaded TCP listener with epoll and EPOLLET in C

I want to write a multithreaded TCP listener using epoll and EPOLLET. I have seen that there are several possibilities: Each thread has its own epoll fd, does bind() using SO_REUSEPORT (but only up Linux kernel 3.9) and handles its own connections.…
user5004112
1
vote
2 answers

Can epoll_wait() > 1 with only 1 socket and 1 event -- EPOLLIN?

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…
Hei
  • 1,844
  • 3
  • 21
  • 35
1
vote
1 answer

epoll with edge triggering, one shot and multithreading

This is a question regarding this answer: https://stackoverflow.com/a/14241095/2332808 (would comment it but newly created accounts apparently can't, sorry for the noise. Ressources on epollet/multithreading are hard to find...) It suggests using…
Asmadeus
  • 300
  • 2
  • 11
0
votes
1 answer

epoll() EPOLLET event handling is skipped

I wrote a simple client-server application. When I started testing, I noticed that not all events are processed properly when the EPOLLET flag is set for socket fd. In the loop, I connected to the server and sent some data to it. For the test, I…
0
votes
2 answers

Linux edge triggered epoll avoiding multiple recv calls for close

I'm trying to understand if its possible to use edge-triggered epoll and avoid the need to call recv() to read from an epoll triggered READ event multiple times, every single time... Take this scenario: Server sends client say 64 bytes and then…
ByteMe95
  • 836
  • 1
  • 6
  • 18
0
votes
0 answers

Can non-blocking sockets be used with epoll's level triggered mode?

Currently I have a server application which supports multiple client sessions. Server is running with epoll's edge triggered mode. The sockets which are used inside the server are all non-blocking in nature. The main epoll loop looks something like…
0
votes
0 answers

Is it possible to use EPOLL to send tasks to multiple client

I am building a server/client application. The server will need to deal with less than 1000+ clients. I currently have a simple EPOLL implementation to be able to receive information from the clients to the server. However, I will need to be able to…
Alex Erling
  • 307
  • 4
  • 19
0
votes
1 answer

Incorrect EPOLLET behavior?

Please consider the following program: #define _GNU_SOURCE #include #include #include #include #include #include #include int verify(int result, const char *msg) { if(…
Shachar Shemesh
  • 8,193
  • 6
  • 25
  • 57
0
votes
1 answer

does epoll_wait() report all close socket events?

or do I need to watch too for the return values of read() or write() to know when to close a socket or it depends on some flags? this question is for epoll in edge triggered mode
porente
  • 371
  • 2
  • 14
0
votes
2 answers

multithreaded epoll server: wake up N threads sleeping on the same epoll fd

I have a multithreaded epoll server. I create an epoll fd, then I will have X threads sleeping, waiting with epoll_wait() any event from that SAME epoll fd. Now my question is this: how can I wakeup N threads, with N > 1 && N < X? Until now, I've…
Marco Pagliaricci
  • 1,366
  • 17
  • 31