networking · beginner · ~15 min

Did accept return a connection?

Interpret accept()'s return.

Challenge

Implement int accept_ok(int rc) returning 1 if accept() returned a valid fd (rc >= 0), else 0.

Starter code

int accept_ok(int rc) {
    /* TODO */
    return 0;
}

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