From 64069a92ef7a29c32a854f04f0d2a2371c9e67fe Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 8 Nov 2011 12:10:55 +0000 Subject: [PATCH] Expose Linux' cork functionality which allows us to aggregate TCP data in a controlled manner. Unfortunately there is no equivalent for Windows. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4781 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- common/network/TcpSocket.cxx | 11 +++++++++++ common/network/TcpSocket.h | 1 + 2 files changed, 12 insertions(+) diff --git a/common/network/TcpSocket.cxx b/common/network/TcpSocket.cxx index 7e115881..23cc49bc 100644 --- a/common/network/TcpSocket.cxx +++ b/common/network/TcpSocket.cxx @@ -309,6 +309,17 @@ bool TcpSocket::enableNagles(int sock, bool enable) { return true; } +bool TcpSocket::cork(int sock, bool enable) { +#ifndef TCP_CORK + return false; +#else + int one = enable ? 1 : 0; + if (setsockopt(sock, IPPROTO_TCP, TCP_CORK, (char *)&one, sizeof(one)) < 0) + return false; + return true; +#endif +} + bool TcpSocket::isSocket(int sock) { struct sockaddr_in info; diff --git a/common/network/TcpSocket.h b/common/network/TcpSocket.h index f45c2eeb..b0bba53b 100644 --- a/common/network/TcpSocket.h +++ b/common/network/TcpSocket.h @@ -56,6 +56,7 @@ namespace network { virtual void shutdown(); static bool enableNagles(int sock, bool enable); + static bool cork(int sock, bool enable); static bool isSocket(int sock); static bool isConnected(int sock); static int getSockPort(int sock); -- 2.39.5