]> git.tdb.fi Git - libs/net.git/blobdiff - source/net/socket.cpp
Add a dynamic receiver class for more flexible packet handling
[libs/net.git] / source / net / socket.cpp
index 877c1da2b99a31d586b9f5832717411cee96d625..2a1a71c0a4b3aa404b616f09a7be6e1799660c27 100644 (file)
@@ -1,8 +1,8 @@
 #include "platform_api.h"
+#include "socket.h"
 #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;
@@ -29,8 +29,13 @@ Socket::Socket(Family af, int type, int proto):
 {
        mode = IO::M_RDWR;
 
-       // TODO use SOCK_CLOEXEC on Linux
+#ifdef __linux__
+       type |= SOCK_CLOEXEC;
+#endif
        priv->handle = socket(family_to_sys(af), type, proto);
+#ifndef __linux__
+       set_inherit(false);
+#endif
 
        platform_init();
 }