From d9ddf9b24a691bdb48379f156439737aa3411002 Mon Sep 17 00:00:00 2001 From: Ron Koenderink Date: Mon, 20 Aug 2007 19:59:12 +0000 Subject: [PATCH] (tcp_connect, hostconnect) [_WIN32]: Replace close() with closesocket() as Windows close() does not support closing socket connections. --- src/client/host.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/client/host.c b/src/client/host.c index b32b6928..7297c79f 100644 --- a/src/client/host.c +++ b/src/client/host.c @@ -48,7 +48,7 @@ #include #include #else -#include +#include #endif #include "misc.h" @@ -82,8 +82,11 @@ tcp_connect(char *host, char *serv) if (connect(sockfd, res->ai_addr, res->ai_addrlen) == 0) break; /* success */ - +#ifdef _WIN32 + closesocket(sockfd); /* ignore this one */ +#else close(sockfd); /* ignore this one */ +#endif } while ((res = res->ai_next) != NULL); if (res == NULL) { /* errno set from final connect() */ @@ -152,8 +155,10 @@ hostconnect(struct sockaddr_in *addr) if (connect(s, (struct sockaddr *)addr, sizeof(*addr)) < 0) { #ifdef _WIN32 errno = WSAGetLastError(); -#endif + (void)closesocket(s); +#else (void)close(s); +#endif return -1; } return s;