]> git.tdb.fi Git - libs/net.git/blobdiff - source/net/unix/socket.cpp
Add a dynamic receiver class for more flexible packet handling
[libs/net.git] / source / net / unix / socket.cpp
index 970b9aedd3be443dff55e6500a296719041ea678..2c1e2ad8d355ac9e0fe9a31b5292f0709535c2f8 100644 (file)
@@ -1,14 +1,16 @@
+#include "platform_api.h"
+#include "socket.h"
 #include <cerrno>
 #include <unistd.h>
 #include <fcntl.h>
-#include "platform_api.h"
 #include <msp/core/systemerror.h>
 #include <msp/io/handle_private.h>
 #include <msp/time/rawtime_private.h>
 #include "sockaddr_private.h"
-#include "socket.h"
 #include "socket_private.h"
 
+using namespace std;
+
 namespace Msp {
 namespace Net {
 
@@ -58,11 +60,11 @@ 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)
        {
-               if(errno==EAGAIN)
+               if(errno==EAGAIN || errno==EWOULDBLOCK)
                        return 0;
                else
                        throw system_error(func);