commit b035dea3ffbccef8840001f0bb9195017a483c09
parent cdc2648d40104c5aad735a01ad613bf971f38e7e
Author: Joris Vink <joris@coders.se>
Date: Sun, 26 Apr 2015 21:09:46 +0200
Make socket error messages more understandable.
Diffstat:
1 file changed, 5 insertions(+), 0 deletions(-)
diff --git a/src/kore.c b/src/kore.c
@@ -230,12 +230,14 @@ kore_server_bind(const char *ip, const char *port)
kore_mem_free(l);
freeaddrinfo(results);
kore_debug("socket(): %s", errno_s);
+ printf("failed to create socket: %s\n", errno_s);
return (KORE_RESULT_ERROR);
}
if (!kore_connection_nonblock(l->fd)) {
kore_mem_free(l);
freeaddrinfo(results);
+ printf("failed to make socket non blocking: %s\n", errno_s);
return (KORE_RESULT_ERROR);
}
@@ -246,6 +248,7 @@ kore_server_bind(const char *ip, const char *port)
kore_mem_free(l);
freeaddrinfo(results);
kore_debug("setsockopt(): %s", errno_s);
+ printf("failed to set SO_REUSEADDR: %s\n", errno_s);
return (KORE_RESULT_ERROR);
}
@@ -254,6 +257,7 @@ kore_server_bind(const char *ip, const char *port)
kore_mem_free(l);
freeaddrinfo(results);
kore_debug("bind(): %s", errno_s);
+ printf("failed to bind to %s port %s: %s\n", ip, port, errno_s);
return (KORE_RESULT_ERROR);
}
@@ -263,6 +267,7 @@ kore_server_bind(const char *ip, const char *port)
close(l->fd);
kore_mem_free(l);
kore_debug("listen(): %s", errno_s);
+ printf("failed to listen on socket: %s\n", errno_s);
return (KORE_RESULT_ERROR);
}