networking · beginner · ~15 min
Check the socket() result.
socket() returns a non-negative fd on success or -1 on error. Implement int socket_ok(int fd) returning 1 if fd >= 0, else 0.
int socket_ok(int fd) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.