- linux/windows socket: close socket when connect fails in Socket_connectAsync

pull/239/head
Michael Zillgith 5 years ago
parent 8e95e7dbb8
commit 0bc014580a

@ -431,6 +431,11 @@ Socket_connectAsync(Socket self, const char* address, int port)
if (connect(self->fd, (struct sockaddr *) &serverAddress, sizeof(serverAddress)) < 0) {
if (errno != EINPROGRESS) {
if (close(self->fd) == -1) {
if (DEBUG_SOCKET)
printf("SOCKET: failed to close socket (errno: %i)\n", errno);
}
self->fd = -1;
return false;
}

@ -386,6 +386,7 @@ Socket_connectAsync(Socket self, const char* address, int port)
if (connect(self->fd, (struct sockaddr *) &serverAddress, sizeof(serverAddress)) == SOCKET_ERROR) {
if (WSAGetLastError() != WSAEWOULDBLOCK) {
closesocket(self->fd);
self->fd = INVALID_SOCKET;
return false;
}

Loading…
Cancel
Save