networking · beginner · ~15 min

Clamp the listen backlog

Bound a listen() backlog argument.

Challenge

Implement int clamp_backlog(int requested, int max) returning requested capped at max, and at least 0.

Starter code

int clamp_backlog(int requested, int max) {
    /* TODO */
    return 0;
}

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