X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fmoof%2Fsocket.hh;h=a7d02f92e8be64000d802c0bae7237e6ff7ec493;hp=f4d2c82609e433d95cc8cc6ce2cf6429b291e2d7;hb=44b3014bce798789e795242d1556cb7449e6386a;hpb=831f04d4bc19a390415ac0bbac4331c7a65509bc diff --git a/src/moof/socket.hh b/src/moof/socket.hh index f4d2c82..a7d02f9 100644 --- a/src/moof/socket.hh +++ b/src/moof/socket.hh @@ -12,11 +12,6 @@ #ifndef _MOOF_SOCKET_HH_ #define _MOOF_SOCKET_HH_ -/** - * \file socket.hh - * Network-related classes, including a reinterpreted sockets API. - */ - #include #include #include @@ -24,11 +19,7 @@ #include #include -#if HAVE_FCNTL_H #include -#else -#error No alternative to fcntl implemented yet. -#endif #if defined(_WIN32) #include @@ -44,11 +35,10 @@ #include #endif -#include +#include #include #include - #ifndef AI_ADDRCONFIG #define AI_ADDRCONFIG 0 #endif @@ -58,6 +48,11 @@ #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 protocols_; - mutex mutex_; + + MOOF_DECLARE_MUTEX(mutex_); };