networking · beginner · ~15 min

Valid port number?

Bound-check a port number.

Challenge

Implement int is_valid_port(int p) returning 1 if p is a usable TCP/UDP port (1..65535), else 0.

Starter code

int is_valid_port(int p) {
    /* TODO */
    return 0;
}

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