]> git.tdb.fi Git - libs/net.git/blobdiff - source/net/socket.cpp
Implement the required virtual functions in Socket
[libs/net.git] / source / net / socket.cpp
index e8e5eaf6275eddb27634a0d473377bed18570d8b..85cc9872a0df0a802555e80e63df446a8f568fc8 100644 (file)
@@ -5,6 +5,8 @@
 #include "socket.h"
 #include "socket_private.h"
 
+using namespace std;
+
 namespace Msp {
 namespace Net {
 
@@ -29,6 +31,7 @@ Socket::Socket(Family af, int type, int proto):
 {
        mode = IO::M_RDWR;
 
+       // TODO use SOCK_CLOEXEC on Linux
        priv->handle = socket(family_to_sys(af), type, proto);
 
        platform_init();
@@ -44,13 +47,22 @@ Socket::~Socket()
 
 void Socket::set_block(bool b)
 {
-       mode = (mode&~IO::M_NONBLOCK);
-       if(b)
-               mode = (mode|IO::M_NONBLOCK);
-
+       IO::adjust_mode(mode, IO::M_NONBLOCK, !b);
        priv->set_block(b);
 }
 
+void Socket::set_inherit(bool i)
+{
+       IO::adjust_mode(mode, IO::M_INHERIT, i);
+       priv->set_inherit(i);
+}
+
+const IO::Handle &Socket::get_handle(IO::Mode)
+{
+       // TODO could this be implemented somehow?
+       throw logic_error("Socket::get_handle");
+}
+
 const IO::Handle &Socket::get_event_handle()
 {
        return priv->event;