networking · beginner · ~15 min

Active connections

Track concurrent connection count.

Challenge

A server processes 'c' (a client connected) and 'd' (a client disconnected). Implement int active_connections(const char *ops) returning the number connected at the end (a 'd' with none connected is ignored).

Starter code

int active_connections(const char *ops) {
    /* TODO */
    return 0;
}

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