#include "logger.h"
#include "oic_malloc.h"
#include "oic_string.h"
+#include "iotivity_debug.h"
/**
* Logging tag for module name.
VERIFY_NON_NULL(handle, TAG, "thread pool handle");
#endif
+#ifdef WSA_WAIT_EVENT_0
+ // Windows-specific initialization.
+ WORD wVersionRequested = MAKEWORD(2, 2);
+ WSADATA wsaData = {.wVersion = 0};
+ int err = WSAStartup(wVersionRequested, &wsaData);
+ if (0 != err)
+ {
+ OIC_LOG_V(ERROR, TAG, "%s: WSAStartup failed: %i", __func__, err);
+ return CA_STATUS_FAILED;
+ }
+ OIC_LOG(DEBUG, TAG, "WSAStartup Succeeded");
+#endif
+
g_networkChangeCallback = netCallback;
g_networkPacketCallback = networkPacketCallback;
g_errorCallback = errorCallback;
CADeInitializeIPGlobals();
CAIPDeinitializeQueueHandles();
#endif
+
+#ifdef WSA_WAIT_EVENT_0
+ // Windows-specific clean-up.
+ OC_VERIFY(0 == WSACleanup());
+#endif
}
#ifndef SINGLE_THREAD
if (caglobals.ip.terminate)
{
caglobals.ip.shutdownEvent = WSA_INVALID_EVENT;
- WSACleanup();
}
}
{
return res;
}
-#if defined (_WIN32)
- WORD wVersionRequested = MAKEWORD(2, 2);
- WSADATA wsaData ={.wVersion = 0};
- int err = WSAStartup(wVersionRequested, &wsaData);
- if (err != 0)
- {
- OIC_LOG_V(ERROR, TAG, "WSAStartup failed: %i", err);
- return CA_STATUS_FAILED;
- }
- OIC_LOG(DEBUG, TAG, "WSAStartup Succeeded");
-#endif
if (!IPv4MulticastAddress.s_addr)
{
(void)inet_pton(AF_INET, IPv4_MULTICAST, &IPv4MulticastAddress);
caglobals.ip.wsaRecvMsg = NULL;
GUID GuidWSARecvMsg = WSAID_WSARECVMSG;
DWORD copied = 0;
- err = WSAIoctl(caglobals.ip.u4.fd, SIO_GET_EXTENSION_FUNCTION_POINTER, &GuidWSARecvMsg, sizeof(GuidWSARecvMsg), &(caglobals.ip.wsaRecvMsg), sizeof(caglobals.ip.wsaRecvMsg), &copied, 0, 0);
+ int err = WSAIoctl(caglobals.ip.u4.fd, SIO_GET_EXTENSION_FUNCTION_POINTER, &GuidWSARecvMsg, sizeof(GuidWSARecvMsg), &(caglobals.ip.wsaRecvMsg), sizeof(caglobals.ip.wsaRecvMsg), &copied, 0, 0);
if (0 != err)
{
OIC_LOG_V(ERROR, TAG, "WSAIoctl failed %i", WSAGetLastError());
#ifdef __WITH_TLS__
#include "ca_adapter_net_ssl.h"
#endif
+#include "iotivity_debug.h"
/**
* Logging tag for module name.
VERIFY_NON_NULL(handle, TAG, "thread pool handle");
#endif
+#ifdef WSA_WAIT_EVENT_0
+ // Windows-specific initialization.
+ WORD wVersionRequested = MAKEWORD(2, 2);
+ WSADATA wsaData = {.wVersion = 0};
+ int err = WSAStartup(wVersionRequested, &wsaData);
+ if (0 != err)
+ {
+ OIC_LOG_V(ERROR, TAG, "%s: WSAStartup failed: %i", __func__, err);
+ return CA_STATUS_FAILED;
+ }
+ OIC_LOG(DEBUG, TAG, "WSAStartup Succeeded");
+#endif
+
g_networkChangeCallback = netCallback;
g_connectionChangeCallback = connCallback;
g_networkPacketCallback = networkPacketCallback;
{
CAStopTCP();
CATCPSetPacketReceiveCallback(NULL);
+
+#ifdef WSA_WAIT_EVENT_0
+ // Windows-specific clean-up.
+ OC_VERIFY(0 == WSACleanup());
+#endif
}
void CATCPSendDataThread(void *threadData)
if (caglobals.tcp.terminate)
{
caglobals.tcp.updateEvent = WSA_INVALID_EVENT;
- WSACleanup();
}
}