networking · advanced · ~15 min
`bind`/`listen`/`accept`; the lifecycle of a listening socket.
Implement int single_echo_server(int port) that:
127.0.0.1:port,The grader connects a client thread to port and asserts the round-trip.
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
int single_echo_server(int port) {
/* TODO */
return -1;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.