networking · intermediate · ~15 min · safe pentest lab
Accept → recv → send → close, all on the same per-client fd.
Implement int echo_once(int listening_fd) that:
listening_fd.The traditional first server. Accept one client, read whatever they send, write it back, close.
#include <sys/socket.h>
#include <unistd.h>
int echo_once(int listening_fd) {
/* TODO */
return -1;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.