]> 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 f4fab44c478d491f0677b333dfc26a853113be78..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,6 +74,10 @@ void Socket::Private::set_block(bool b)
        ioctlsocket(handle, FIONBIO, &flag);
 }
 
+void Socket::Private::set_inherit(bool)
+{
+}
+
 int Socket::Private::set_option(int level, int optname, const void *optval, socklen_t optlen)
 {
        return setsockopt(handle, level, optname, reinterpret_cast<const char *>(optval), optlen);
@@ -81,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)
        {