summaryrefslogtreecommitdiffstats
path: root/net/base/net_util.cc
diff options
context:
space:
mode:
authorerikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-11 01:06:15 +0000
committererikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-11 01:06:15 +0000
commitf6f1ba3cfd72905cd900e6266589ccb4a1650cb0 (patch)
tree957e236fd4f8b3e3578a7c7208e3ea6a79c65aee /net/base/net_util.cc
parent043c9a78957bf3f7de4b53e41ec91bf22be69949 (diff)
downloadchromium_src-f6f1ba3cfd72905cd900e6266589ccb4a1650cb0.zip
chromium_src-f6f1ba3cfd72905cd900e6266589ccb4a1650cb0.tar.gz
chromium_src-f6f1ba3cfd72905cd900e6266589ccb4a1650cb0.tar.bz2
Change made by external contributor Ibrar Ahmed (ibrar.ahmad@gmail.com), reviewed by erikkay:
http://codereview.chromium.org/6577/show ports listen_socket and telnet_server to POSIX I had to make some changes to get this to work on Mac and to fix a few regressions it caused in Windows, so please take a fresh look at this diff Dan. Ibrar, please take a look at the changes from your patch to mine (you may need to diff listen_socket_unittest.h with listen_socket_unittest.cc manually since I moved a bunch of code here). Some were bugs that I should have caught in review, some were bugs that only got tickled on the Mac, others were just cleanup. Comments welcome. Review URL: http://codereview.chromium.org/9260 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5153 0039d316-1c4b-4281-b951-d872f2087c98
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