Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(628)

Unified Diff: runtime/bin/socket_win.cc

Issue 12380032: Added Socket::SetBlocking() and Socket::SetNonBlocking(). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/socket_macos.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket_win.cc
===================================================================
--- runtime/bin/socket_win.cc (revision 19251)
+++ runtime/bin/socket_win.cc (working copy)
@@ -288,4 +288,26 @@
client_socket->Close();
}
+
+static bool SetBlockingHelper(intptr_t fd, bool blocking) {
+ SocketHandle* handle = reinterpret_cast<SocketHandle*>(fd);
+ u_long iMode = blocking ? 0 : 1;
+ int status = ioctlsocket(handle->socket(), FIONBIO, &iMode);
+ if (status != NO_ERROR) {
+ Log::PrintErr("ioctlsocket FIONBIO failed: %d\n", status);
+ return false;
+ }
+ return true;
+}
+
+
+bool Socket::SetNonBlocking(intptr_t fd) {
+ return SetBlockingHelper(fd, false);
+}
+
+
+bool Socket::SetBlocking(intptr_t fd) {
+ return SetBlockingHelper(fd, true);
+}
+
#endif // defined(TARGET_OS_WINDOWS)
« no previous file with comments | « runtime/bin/socket_macos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698