Skip to content
Snippets Groups Projects
Commit 8f7e1bde authored by Andreas Traczyk's avatar Andreas Traczyk
Browse files

natpmp: use winsock poll on Windows

Change-Id: I7b4ee7d3bd2b409ad098515c2a9c61eb67ce0833
parent 2ef5b66c
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,19 @@
#include "nat_pmp.h"
#if HAVE_LIBNATPMP
#ifdef _WIN32
// On Windows we assume WSAStartup is called during DHT initialization
#include <winsock2.h>
#include <ws2tcpip.h>
#else
#include <poll.h>
#endif
#ifdef _WIN32
#define _poll(fds, nfds, timeout) WSAPoll(fds, nfds, timeout)
#else
#define _poll(fds, nfds, timeout) poll(fds, nfds, timeout)
#endif
namespace dhtnet {
namespace upnp {
......@@ -340,8 +352,9 @@ NatPmp::readResponse(natpmp_t& handle, natpmpresp_t& response)
struct timeval timeout;
getnatpmprequesttimeout(&handle, &timeout);
uint64_t millis = (timeout.tv_sec * (uint64_t)1000) + (timeout.tv_usec / 1000);
// Wait for data.
if (poll(&fds, 1, millis) == -1) {
if (_poll(&fds, 1, millis) == -1) {
err = NATPMP_ERR_SOCKETERROR;
break;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment