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

Unified Diff: net/socket/tcp_socket.cc

Issue 1728853006: net: merge two versions of SetTCPNoDelay() function into one (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: export it Created 4 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 | « net/socket/tcp_socket.h ('k') | net/socket/tcp_socket_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/tcp_socket.cc
diff --git a/net/socket/tcp_socket.cc b/net/socket/tcp_socket.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ad5250620d0f1b1eb09c6c100c5d67f4babc4a6d
--- /dev/null
+++ b/net/socket/tcp_socket.cc
@@ -0,0 +1,29 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/socket/tcp_socket.h"
+
+#include "build/build_config.h"
+
+#if defined(OS_POSIX)
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#elif defined(OS_WIN)
+#include <winsock2.h>
+#endif
+
+namespace net {
+
+bool SetTCPNoDelay(SocketDescriptor socket, bool no_delay) {
+#if defined(OS_POSIX)
+ int on = no_delay ? 1 : 0;
+#elif defined(OS_WIN)
+ BOOL on = no_delay ? TRUE : FALSE;
+#endif
+ return setsockopt(socket, IPPROTO_TCP, TCP_NODELAY,
+ reinterpret_cast<const char*>(&on), sizeof(on)) == 0;
+}
+
+} // namespace net
« no previous file with comments | « net/socket/tcp_socket.h ('k') | net/socket/tcp_socket_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698