提交 46c2d714 authored 作者: Mathieu Rene's avatar Mathieu Rene

fix windows build

上级 90da341a
...@@ -613,8 +613,9 @@ ESL_DECLARE(esl_status_t) esl_connect_timeout(esl_handle_t *handle, const char * ...@@ -613,8 +613,9 @@ ESL_DECLARE(esl_status_t) esl_connect_timeout(esl_handle_t *handle, const char *
int rval = 0; int rval = 0;
const char *hval; const char *hval;
struct addrinfo hints = { 0 }, *result; struct addrinfo hints = { 0 }, *result;
#ifndef WIN32
int fd_flags; int fd_flags;
#ifdef WIN32 #else
WORD wVersionRequested = MAKEWORD(2, 0); WORD wVersionRequested = MAKEWORD(2, 0);
WSADATA wsaData; WSADATA wsaData;
int err = WSAStartup(wVersionRequested, &wsaData); int err = WSAStartup(wVersionRequested, &wsaData);
...@@ -669,11 +670,20 @@ ESL_DECLARE(esl_status_t) esl_connect_timeout(esl_handle_t *handle, const char * ...@@ -669,11 +670,20 @@ ESL_DECLARE(esl_status_t) esl_connect_timeout(esl_handle_t *handle, const char *
if (timeout) { if (timeout) {
fd_set wfds; fd_set wfds;
struct timeval tv = { timeout / 1000, (timeout % 1000) * 1000 }; struct timeval tv;
int r; int r;
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout % 1000) * 1000;
FD_ZERO(&wfds); FD_ZERO(&wfds);
#ifdef WIN32
#pragma warning( push )
#pragma warning( disable : 4127 )
FD_SET(handle->sock, &wfds);
#pragma warning( pop )
#else
FD_SET(handle->sock, &wfds); FD_SET(handle->sock, &wfds);
#endif
r = select(handle->sock + 1, NULL, &wfds, NULL, &tv); r = select(handle->sock + 1, NULL, &wfds, NULL, &tv);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论