networking · intermediate · ~15 min
Map common socket errnos to names.
Implement const char *sock_err_name(int err) returning "ECONNREFUSED", "ETIMEDOUT", or "EADDRINUSE" for those errno values, else "OTHER".
#include <errno.h>
const char *sock_err_name(int err) {
/* TODO */
return "OTHER";
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.