summaryrefslogtreecommitdiff
path: root/sockets.c
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2019-04-19 02:15:41 +0200
committerLuke Bratch <luke@bratch.co.uk>2019-04-19 02:15:41 +0200
commitf4070050375a621d4297e0629c0072519cdf5d2d (patch)
tree7daecca434443eaeef32700be0d97feaaaa54021 /sockets.c
parentfdbbc1afcec71c7a447d3fba98db2896289dd7e0 (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.c34
1 files changed, 17 insertions, 17 deletions
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) {