Logan oos Even
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
18 additions and
0 deletions
-
tools/n2n-portfwd.c
|
|
@ -80,6 +80,7 @@ static void term_handler (int sig) { |
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------
|
|
|
|
// PLATFORM-DEPENDANT CODE
|
|
|
|
|
|
|
|
|
|
|
|
SOCKET connect_to_management_port (n2n_portfwd_conf_t *ppp) { |
|
|
@ -87,6 +88,23 @@ SOCKET connect_to_management_port (n2n_portfwd_conf_t *ppp) { |
|
|
|
SOCKET ret; |
|
|
|
struct sockaddr_in sock_addr; |
|
|
|
|
|
|
|
#if defined(WIN32) |
|
|
|
// Windows requires a call to WSAStartup() before it can work with sockets
|
|
|
|
WORD wVersionRequested; |
|
|
|
WSADATA wsaData; |
|
|
|
int err; |
|
|
|
|
|
|
|
// Use the MAKEWORD(lowbyte, highbyte) macro declared in Windef.h
|
|
|
|
wVersionRequested = MAKEWORD(2, 2); |
|
|
|
|
|
|
|
err = WSAStartup(wVersionRequested, &wsaData); |
|
|
|
if (err != 0) { |
|
|
|
// tell the user that we could not find a usable Winsock DLL
|
|
|
|
traceEvent(TRACE_ERROR, "WSAStartup failed with error: %d\n", err); |
|
|
|
return -1; |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
ret = socket (PF_INET, SOCK_DGRAM, 0); |
|
|
|
if((int)ret < 0) |
|
|
|
return -1; |
|
|
|