--- a/src/irc.c +++ b/src/irc.c @@ -62,12 +62,13 @@ break; } close (csocket); + csocket = -1; } if (result != NULL) freeaddrinfo (result); - if (csocket < 0) { + if (csocket == -1) { perror ("Cannot connect"); return NULL; }