]> git.tdb.fi Git - libs/net.git/blobdiff - source/net/windows/socket.cpp
Don't create the WinSock helper until the first socket is created
[libs/net.git] / source / net / windows / socket.cpp
index dfcff623c328f4f03b2a7129a1931891a80c140b..eadc22af3a2de5355c349d16e201f8d1ec01b032 100644 (file)
@@ -1,9 +1,9 @@
-#include <iostream>
 #include "platform_api.h"
+#include "socket.h"
+#include <iostream>
 #include <msp/core/systemerror.h>
 #include <msp/io/handle_private.h>
 #include "sockaddr_private.h"
-#include "socket.h"
 #include "socket_private.h"
 
 using namespace std;
@@ -27,7 +27,7 @@ public:
        }
 };
 
-WinSockHelper wsh;
+unique_ptr<WinSockHelper> wsh;
 
 }
 
@@ -37,6 +37,8 @@ namespace Net {
 
 void Socket::platform_init()
 {
+       if(!wsh)
+               wsh = make_unique<WinSockHelper>();
        *priv->event = CreateEvent(0, false, false, 0);
 }