networking · beginner · ~15 min

Set the non-blocking flag

Add a flag bit with bitwise OR.

Challenge

Implement int add_nonblock(int flags, int o_nonblock) returning flags with the O_NONBLOCK bit OR-ed in.

Starter code

int add_nonblock(int flags, int o_nonblock) {
    /* TODO */
    return flags;
}

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