#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>
*/
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
}
*/
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;
}
void socket(moof::socket sock)
{
- mutex::scoped_lock lock(mutex_);
+ MOOF_MUTEX_LOCK(mutex_);
socket_ = sock;
}
moof::socket socket_;
std::vector<function> protocols_;
- mutex mutex_;
+
+ MOOF_DECLARE_MUTEX(mutex_);
};