]> Dogcows Code - chaz/yoink/blobdiff - src/moof/socket.hh
pch support
[chaz/yoink] / src / moof / socket.hh
index f4d2c82609e433d95cc8cc6ce2cf6429b291e2d7..a7d02f92e8be64000d802c0bae7237e6ff7ec493 100644 (file)
 #ifndef _MOOF_SOCKET_HH_
 #define _MOOF_SOCKET_HH_
 
-/**
- * \file socket.hh
- * Network-related classes, including a reinterpreted sockets API.
- */
-
 #include <algorithm>
 #include <cstring>
 #include <iostream>
 #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>
 #include <sys/types.h>
 #endif
 
-#include <moof/log.hh>
+#include <moof/debug.hh>
 #include <moof/packet.hh>
 #include <moof/thread.hh>
 
-
 #ifndef AI_ADDRCONFIG
 #define AI_ADDRCONFIG 0
 #endif
 #endif
 
 
+/**
+ * \file socket.hh
+ * Network-related classes, including a reinterpreted sockets API.
+ */
+
 namespace moof {
 
 
@@ -733,13 +728,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 +746,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;
        }
 
 
@@ -1005,7 +1001,7 @@ public:
 
        void socket(moof::socket sock)
        {
-               mutex::scoped_lock lock(mutex_);
+               MOOF_MUTEX_LOCK(mutex_);
                socket_ = sock;
        }
 
@@ -1049,7 +1045,8 @@ private:
 
        moof::socket                    socket_;
        std::vector<function>   protocols_;
-       mutex                                   mutex_;
+
+       MOOF_DECLARE_MUTEX(mutex_);
 };
 
 
This page took 0.018923 seconds and 4 git commands to generate.