summaryrefslogtreecommitdiff
path: root/tools/emulator/opengl/shared/OpenglCodecCommon/TcpStream.cpp
diff options
context:
space:
mode:
authorDavid Turner <digit@android.com>2011-08-16 00:55:43 +0200
committerDavid Turner <digit@android.com>2011-08-16 00:55:43 +0200
commit3ae6928d8d3bfb909b72b80e8aaf043325959c4b (patch)
tree0979613fad063e205cb734f665d4f69be4b705de /tools/emulator/opengl/shared/OpenglCodecCommon/TcpStream.cpp
parent36371ff3eb65acbac977f349514a49fc3ade4290 (diff)
emulator opengles: improve TcpStream throughput
This patch improves the performance of the TcpStream implementation on the host by disabling the Nagle algorithm, thus improving the bandwidth of small packets. When used with the corresponding change in the emulator, this significantly improves the speed of OpenGLES emulation for many applications. Change-Id: Ic09e51ecddf04bc7d667f46e1d260030d5fcad88
Diffstat (limited to 'tools/emulator/opengl/shared/OpenglCodecCommon/TcpStream.cpp')
-rw-r--r--tools/emulator/opengl/shared/OpenglCodecCommon/TcpStream.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/TcpStream.cpp b/tools/emulator/opengl/shared/OpenglCodecCommon/TcpStream.cpp
index 4e947daa5..c057ff991 100644
--- a/tools/emulator/opengl/shared/OpenglCodecCommon/TcpStream.cpp
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/TcpStream.cpp
@@ -23,6 +23,9 @@
#ifndef _WIN32
#include <netinet/in.h>
+#include <netinet/tcp.h>
+#else
+#include <ws2tcpip.h>
#endif
TcpStream::TcpStream(size_t bufSize) :
@@ -39,6 +42,15 @@ TcpStream::TcpStream(int sock, size_t bufSize) :
m_bufsize(bufSize),
m_buf(NULL)
{
+ // disable Nagle algorithm to improve bandwidth of small
+ // packets which are quite common in our implementation.
+#ifdef _WIN32
+ DWORD flag;
+#else
+ int flag;
+#endif
+ flag = 1;
+ setsockopt( sock, IPPROTO_TCP, TCP_NODELAY, (const char*)&flag, sizeof(flag) );
}
TcpStream::~TcpStream()