networking · intermediate · ~15 min
Detect the would-block condition.
On a non-blocking socket, a not-ready operation returns -1 with errno EAGAIN/EWOULDBLOCK. Implement int would_block(int rc, int err, int eagain) returning 1 if rc < 0 && err == eagain, else 0.
int would_block(int rc, int err, int eagain) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.