Fixes for windows (#45)
* init Net system on Windows * propagate DNS error * Add zlib 1.2.11 sources * link zlib statically for windows * remove not implemented function declaration * fix connect on Windows
This commit is contained in:
committed by
Benjamin Sergeant
parent
b178ba16af
commit
58d65926bb
@ -27,7 +27,7 @@ namespace ix
|
||||
_done(false),
|
||||
_id(_nextId++)
|
||||
{
|
||||
|
||||
initNetSystem();
|
||||
}
|
||||
|
||||
DNSLookup::~DNSLookup()
|
||||
@ -137,6 +137,11 @@ namespace ix
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!_errMsg.empty())
|
||||
{
|
||||
errMsg = _errMsg;
|
||||
}
|
||||
|
||||
std::unique_lock<std::mutex> rlock(_resMutex);
|
||||
return _res;
|
||||
}
|
||||
|
39
ixwebsocket/IXNetSystem.cpp
Normal file
39
ixwebsocket/IXNetSystem.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* IXNetSystem.cpp
|
||||
* Author: Benjamin Sergeant
|
||||
* Copyright (c) 2019 Machine Zone. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "IXNetSystem.h"
|
||||
|
||||
namespace ix
|
||||
{
|
||||
bool initNetSystem()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
WORD wVersionRequested;
|
||||
WSADATA wsaData;
|
||||
int err;
|
||||
|
||||
/* Use the MAKEWORD(lowbyte, highbyte) macro declared in Windef.h */
|
||||
wVersionRequested = MAKEWORD(2, 2);
|
||||
|
||||
err = WSAStartup(wVersionRequested, &wsaData);
|
||||
|
||||
return err == 0;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool uninitNetSystem()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
int err = WSACleanup();
|
||||
|
||||
return err == 0;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
}
|
@ -23,3 +23,9 @@
|
||||
# include <sys/time.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
namespace ix
|
||||
{
|
||||
bool initNetSystem();
|
||||
bool uninitNetSystem();
|
||||
}
|
||||
|
@ -57,10 +57,10 @@ namespace ix
|
||||
SocketConnect::configure(fd);
|
||||
|
||||
if (::connect(fd, address->ai_addr, address->ai_addrlen) == -1
|
||||
&& errno != EINPROGRESS)
|
||||
&& errno != EINPROGRESS && errno != 0)
|
||||
{
|
||||
closeSocket(fd);
|
||||
errMsg = strerror(errno);
|
||||
closeSocket(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user