aboutsummaryrefslogtreecommitdiff
path: root/ares
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-07-01 13:54:24 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-07-01 13:54:24 +0000
commit8952ef933b89e59c3729694bac971e9f4aa3db30 (patch)
tree1c81f523190540a7057086d51fc45b5c607785b6 /ares
parentb350d5da590f9cd250dbb7af078f17f4437e242f (diff)
Gisle's win32-fix. 'errno' is not used for errors when socket() fails on
Windows.
Diffstat (limited to 'ares')
-rw-r--r--ares/ares_process.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/ares/ares_process.c b/ares/ares_process.c
index a8dd0c750..121c44980 100644
--- a/ares/ares_process.c
+++ b/ares/ares_process.c
@@ -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);
@@ -476,18 +482,20 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server)
return -1;
}
#endif
-
+
/* Connect to the server. */
memset(&sockin, 0, sizeof(sockin));
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;