diff --git a/NetworkClient.cpp b/NetworkClient.cpp index a25e86d54..a6a1b7c3e 100644 --- a/NetworkClient.cpp +++ b/NetworkClient.cpp @@ -25,6 +25,13 @@ #ifdef __linux__ #include #include +#include +#endif + +#ifdef __linux__ +const int yes = 1; +#else +const char yes = 1; #endif using namespace std::chrono_literals; @@ -438,6 +445,13 @@ int NetworkClient::recv_select(SOCKET s, char *buf, int len, int flags) } else { + /*-------------------------------------------------*\ + | Set QUICKACK socket option on Linux to improve | + | performance | + \*-------------------------------------------------*/ +#ifdef __linux__ + setsockopt(s, IPPROTO_TCP, TCP_QUICKACK, &yes, sizeof(yes)); +#endif return(recv(s, buf, len, flags)); } diff --git a/NetworkServer.cpp b/NetworkServer.cpp index 083b45349..8d9f0eb73 100644 --- a/NetworkServer.cpp +++ b/NetworkServer.cpp @@ -26,14 +26,18 @@ #include #include -const char yes = 1; - #ifdef WIN32 #include #else #include #endif +#ifdef __linux__ +const int yes = 1; +#else +const char yes = 1; +#endif + using namespace std::chrono_literals; NetworkClientInfo::NetworkClientInfo() @@ -548,6 +552,13 @@ int NetworkServer::recv_select(SOCKET s, char *buf, int len, int flags) } else { + /*-------------------------------------------------*\ + | Set QUICKACK socket option on Linux to improve | + | performance | + \*-------------------------------------------------*/ +#ifdef __linux__ + setsockopt(s, IPPROTO_TCP, TCP_QUICKACK, &yes, sizeof(yes)); +#endif return(recv(s, buf, len, flags)); } } diff --git a/net_port/net_port.cpp b/net_port/net_port.cpp index 3714642d2..99178a09c 100644 --- a/net_port/net_port.cpp +++ b/net_port/net_port.cpp @@ -29,7 +29,11 @@ #define connect_socklen_t socklen_t #endif +#ifdef __linux__ +const int yes = 1; +#else const char yes = 1; +#endif net_port::net_port() { @@ -328,6 +332,13 @@ void net_port::tcp_close() int net_port::tcp_listen(char * recv_data, int length) { + /*-------------------------------------------------*\ + | Set QUICKACK socket option on Linux to improve | + | performance | + \*-------------------------------------------------*/ +#ifdef __linux__ + setsockopt(sock, IPPROTO_TCP, TCP_QUICKACK, &yes, sizeof(yes)); +#endif return(recv(sock, recv_data, length, 0)); }