networking · beginner · ~15 min
Interpret connect()'s return.
Interpret the return value of a blocking connect().
Implement int connect_succeeded(int rc).
rc: the value connect() returned.Return 1 if rc == 0 (the handshake completed), else 0.
connect_succeeded(0) -> 1
connect_succeeded(-1) -> 0
rc: the return value of connect().
1 if rc == 0, else 0.
A blocking connect() returns 0 once the TCP handshake completes.
int connect_succeeded(int rc) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.