]> Dogcows Code - chaz/yoink/blobdiff - src/moof/socket.hh
begin cleaning up resource management
[chaz/yoink] / src / moof / socket.hh
index f4d2c82609e433d95cc8cc6ce2cf6429b291e2d7..c592fdbfb097dd4488d2590a94c8ce267b9aadcf 100644 (file)
 #include <string>
 #include <vector>
 
-#if HAVE_FCNTL_H
 #include <fcntl.h>
-#else
-#error No alternative to fcntl implemented yet.
-#endif
 
 #if defined(_WIN32)
 #include <winsock2.h>
@@ -44,7 +40,7 @@
 #include <sys/types.h>
 #endif
 
-#include <moof/log.hh>
+#include <moof/debug.hh>
 #include <moof/packet.hh>
 #include <moof/thread.hh>
 
@@ -733,13 +729,13 @@ public:
         */
        void is_blocking(bool is_blocking)
        {
-#ifdef HAVE_FCNTL
+#if defined(_WIN32)
+               u_long value = is_blocking;
+               ioctlsocket(impl_.fd, FIONBIO, &value);
+#else
                int flags = fcntl(impl_.fd, F_GETFL);
                flags = is_blocking ? (flags & ~O_NONBLOCK) : (flags | O_NONBLOCK);
                fcntl(impl_.fd, F_SETFL, flags);
-#elif defined(_WIN32)
-               u_long value = is_blocking;
-               ioctlsocket(impl_.fd, FIONBIO, &value);
 #endif
        }
 
@@ -751,11 +747,12 @@ public:
         */
        bool is_blocking() const
        {
-#ifdef HAVE_FCNTL
+#if defined(_WIN32)
+               return true;
+#else
                int flags = fcntl(impl_.fd, F_GETFL);
                return !(flags & O_NONBLOCK);
 #endif
-               return true;
        }
 
 
This page took 0.019085 seconds and 4 git commands to generate.