From f4070050375a621d4297e0629c0072519cdf5d2d Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Fri, 19 Apr 2019 02:15:41 +0200 Subject: Lots and lots of refactoring and comments work in preparation for more actual IRC/bouncer functionality --- sockets.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'sockets.c') diff --git a/sockets.c b/sockets.c index 6c1370b..40079c2 100644 --- a/sockets.c +++ b/sockets.c @@ -60,22 +60,22 @@ int createclientsocket(char *listenport) { int listener; // listening socket descriptor int rv; // return value for getaddrinfo (for error message) - struct addrinfo hints, *ai, *p; + struct addrinfo hints, *ai, *p; int yes = 1; // for enabling socket options with setsockopt - // get us a socket and bind it - memset(&hints, 0, sizeof hints); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_PASSIVE; + // get us a socket and bind it + memset(&hints, 0, sizeof hints); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + hints.ai_flags = AI_PASSIVE; - if ((rv = getaddrinfo(NULL, listenport, &hints, &ai)) != 0) { - fprintf(stderr, "bouncer-client: %s\n", gai_strerror(rv)); - exit(1); - } + if ((rv = getaddrinfo(NULL, listenport, &hints, &ai)) != 0) { + fprintf(stderr, "bouncer-client: %s\n", gai_strerror(rv)); + exit(1); + } // Try for IPv6 - for (p = ai; p != NULL; p = p->ai_next) { + for (p = ai; p != NULL; p = p->ai_next) { if (p->ai_family == AF_INET6) { listener = socket(p->ai_family, p->ai_socktype, p->ai_protocol); if (listener != -1) { @@ -110,13 +110,13 @@ int createclientsocket(char *listenport) { exit(1); } - // if we got here, it means we didn't get bound - if (p == NULL) { - fprintf(stderr, "bouncer-client: failed to bind\n"); - exit(2); - } + // if we got here, it means we didn't get bound + if (p == NULL) { + fprintf(stderr, "bouncer-client: failed to bind\n"); + exit(2); + } - freeaddrinfo(ai); // all done with this + freeaddrinfo(ai); // all done with this // listen if (listen(listener, BACKLOG) == -1) { -- cgit v1.2.3