]> git.tdb.fi Git - libs/net.git/blobdiff - source/socket.cpp
Update handle types
[libs/net.git] / source / socket.cpp
index c4e98a363a89b9779517f9aab9c95a9cb1a84742..7ff77417c88672b3b703430d65b2035b2d047e91 100644 (file)
@@ -4,7 +4,9 @@
 #include <sys/socket.h>
 #endif
 #include <iostream>
-#include <msp/strings/formatter.h>
+#include <msp/io/handle_private.h>
+#include <msp/strings/format.h>
+#include <msp/time/rawtime_private.h>
 #include <msp/time/units.h>
 #include "socket.h"
 
@@ -49,6 +51,8 @@ Socket::Socket(SocketHandle h, const SockAddr &paddr):
 
 #ifdef WIN32
        event = CreateEvent(0, false, false, 0);
+#else
+       *event = handle;
 #endif
 }
 
@@ -61,6 +65,8 @@ Socket::Socket(Family af, int type, int proto):
 
 #ifdef WIN32
        event = CreateEvent(0, false, false, 0);
+#else
+       *event = handle;
 #endif
 }
 
@@ -84,13 +90,9 @@ void Socket::set_block(bool b)
 #endif
 }
 
-IO::Handle Socket::get_event_handle()
+const IO::Handle &Socket::get_event_handle()
 {
-#ifdef WIN32
        return event;
-#else
-       return handle;
-#endif
 }
 
 
@@ -136,8 +138,7 @@ void Socket::close()
 void Socket::set_timeout(const Time::TimeDelta &timeout)
 {
 #ifndef WIN32
-       timeval tv;
-       timeout.fill_timeval(tv);
+       timeval tv = Time::rawtime_to_timeval(timeout.raw());
        set_option(SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(timeval));
        set_option(SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(timeval));
 #else