diff options
-rw-r--r-- | plop.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -36,6 +36,7 @@ int make_server(const char * node, const char * service) } int server; + int optval = 1; for (it = result; it != NULL; it = it->ai_next) { @@ -44,6 +45,12 @@ int make_server(const char * node, const char * service) if (-1 == server) continue; + if (-1 == setsockopt(server, SOL_SOCKET, SO_REUSEADDR, (char *) &optval, sizeof(optval))) + { + close(server); + continue; + } + if (-1 == fcntl(server, F_SETFL, (fcntl(server, F_GETFL, 0) | O_NONBLOCK))) { close(server); @@ -177,6 +184,11 @@ int main(int argc, char ** argv) fdv[0].events = POLLIN; fdc++; + if (-1 == fdv[0].fd) + { + return 1; // TODO: Document error codes/print usage information + } + while (0 < fdc && -1 != poll(fdv, fdc, -1)) { int shift_by = 0; |