networking · beginner · ~15 min

Count ready descriptors

Scan poll results for ready fds.

Challenge

After poll(), each fd has a revents value (0 = nothing). Implement int count_ready(const int *revents, int n) returning how many are non-zero.

Starter code

int count_ready(const int *revents, int n) {
    /* TODO */
    return 0;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.