1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

Gisle's win32-fix. 'errno' is not used for errors when socket() fails on

Windows.
This commit is contained in:
Daniel Stenberg 2004-07-01 13:54:24 +00:00
parent b350d5da59
commit 8952ef933b

View File

@ -35,6 +35,12 @@
#include "ares_dns.h"
#include "ares_private.h"
#ifdef WIN32
#define GET_ERRNO() WSAGetLastError()
#else
#define GET_ERRNO() errno
#endif
static void write_tcp_data(ares_channel channel, fd_set *write_fds,
time_t now);
static void read_tcp_data(ares_channel channel, fd_set *read_fds, time_t now);
@ -482,12 +488,14 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server)
sockin.sin_family = AF_INET;
sockin.sin_addr = server->addr;
sockin.sin_port = channel->tcp_port;
if (connect(s, (struct sockaddr *) &sockin, sizeof(sockin)) == -1
&& errno != EINPROGRESS)
{
if (connect(s, (struct sockaddr *) &sockin, sizeof(sockin)) == -1) {
int err = GET_ERRNO();
if (err != EINPROGRESS && err != EWOULDBLOCK) {
closesocket(s);
return -1;
}
}
server->tcp_socket = s;
return 0;