diff options
author | Luke Bratch <luke@bratch.co.uk> | 2019-04-19 02:15:41 +0200 |
---|---|---|
committer | Luke Bratch <luke@bratch.co.uk> | 2019-04-19 02:15:41 +0200 |
commit | f4070050375a621d4297e0629c0072519cdf5d2d (patch) | |
tree | 7daecca434443eaeef32700be0d97feaaaa54021 /sockets.c | |
parent | fdbbc1afcec71c7a447d3fba98db2896289dd7e0 (diff) |
Lots and lots of refactoring and comments work in preparation for more actual IRC/bouncer functionality
Diffstat (limited to 'sockets.c')
-rw-r--r-- | sockets.c | 34 |
1 files changed, 17 insertions, 17 deletions
@@ -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) { |