What exactly makes a non-blocking socket block? The possible danger of using epoll() in edge-triggered mode

73 views Asked by At

Say we want to write a server to handle multiple clients by using epoll in edge-triggered mode.
While using epoll() in edge-triggered mode, whenever the server receives the EPOLLOUT or EPOLLIN event, it has to write or read until it receives EWOULDBLOCK or EAGAIN.

Say a client connects and sends a VEEEERY long message. Now the server has to read it until it gets get EWOULDBLOCK or EAGAIN.

Can the server be sure EWOULDBLOCK or EAGAIN is received after some reasonable amount of time and it doesn't end up reading gigabytes of data from that client, while all other clients are waiting?

This isn't just a Yes or No question. I'm looking forward to understanding how this blocking is controlled on the OS level.

0

There are 0 answers