mirror of
https://github.com/ntop/n2n.git
synced 2024-09-19 16:41:11 +02:00
Windows needs special network init (#1034)
This commit is contained in:
parent
cf23457d3b
commit
504a552c77
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user