]> git.tdb.fi Git - libs/net.git/blobdiff - source/net/windows/socket.cpp
Add a dynamic receiver class for more flexible packet handling
[libs/net.git] / source / net / windows / socket.cpp
index a7268e85a65f46bd91e1d752dbfcba4c5fc450c6..eadc22af3a2de5355c349d16e201f8d1ec01b032 100644 (file)
@@ -1,11 +1,13 @@
-#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;
+
 namespace {
 
 class WinSockHelper
@@ -25,7 +27,7 @@ public:
        }
 };
 
-WinSockHelper wsh;
+unique_ptr<WinSockHelper> wsh;
 
 }
 
@@ -35,6 +37,8 @@ namespace Net {
 
 void Socket::platform_init()
 {
+       if(!wsh)
+               wsh = make_unique<WinSockHelper>();
        *priv->event = CreateEvent(0, false, false, 0);
 }
 
@@ -70,7 +74,7 @@ void Socket::Private::set_block(bool b)
        ioctlsocket(handle, FIONBIO, &flag);
 }
 
-void Socket::Private::set_inherit(bool i)
+void Socket::Private::set_inherit(bool)
 {
 }
 
@@ -85,7 +89,7 @@ int Socket::Private::get_option(int level, int optname, void *optval, socklen_t
 }
 
 
-unsigned check_sys_error(int ret, const char *func)
+size_t check_sys_error(make_signed<size_t>::type ret, const char *func)
 {
        if(ret<0)
        {