summaryrefslogtreecommitdiffstats
path: root/net/base/net_util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'net/base/net_util.cc')
-rw-r--r--net/base/net_util.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/net/base/net_util.cc b/net/base/net_util.cc
index 507b7b4..05419fb 100644
--- a/net/base/net_util.cc
+++ b/net/base/net_util.cc
@@ -10,8 +10,14 @@
#include <unicode/uscript.h>
#include <unicode/uset.h>
-#ifdef OS_WIN
+#include "build/build_config.h"
+
+#if defined(OS_WIN)
#include <windows.h>
+#include <winsock2.h>
+#elif defined(OS_POSIX)
+#include <sys/socket.h>
+#include <fcntl.h>
#endif
#include "net/base/net_util.h"
@@ -915,4 +921,16 @@ bool IsPortAllowedByFtp(int port) {
return IsPortAllowedByDefault(port);
}
+int SetNonBlocking(int fd) {
+#if defined(OS_WIN)
+ unsigned long no_block = 1;
+ return ioctlsocket(fd, FIONBIO, &no_block);
+#elif defined(OS_POSIX)
+ int flags = fcntl(fd, F_GETFL, 0);
+ if (-1 == flags)
+ flags = 0;
+ return fcntl(fd, F_SETFL, flags | O_NONBLOCK);
+#endif
+}
+
} // namespace net