summaryrefslogtreecommitdiff
path: root/xs_socket.h
diff options
context:
space:
mode:
Diffstat (limited to 'xs_socket.h')
-rw-r--r--xs_socket.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/xs_socket.h b/xs_socket.h
index 1c73a22..1bd053a 100644
--- a/xs_socket.h
+++ b/xs_socket.h
@@ -182,8 +182,10 @@ int xs_socket_connect(const char *addr, const char *serv)
host.sin_port = htons(atoi(serv));
if ((d = socket(AF_INET, SOCK_STREAM, 0)) != -1) {
- if (connect(d, (struct sockaddr *)&host, sizeof(host)) == -1)
+ if (connect(d, (struct sockaddr *)&host, sizeof(host)) == -1) {
+ close(d);
d = -1;
+ }
}
}