mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-10-23 00:55:20 -04:00
Set TCP_QUICKACK on Linux to improve responsiveness when using client/service configuration
This commit is contained in:
1 parent
2a1b7a9e2e
commit
d09c66900d
3 files changed
+38
-2
No files matched your search
@@ -25,6 +25,13 @@
|
||||
#ifdef __linux__
|
||||
#include <unistd.h>
|
||||
#include <sys/select.h>
|
||||
#include <netinet/tcp.h>
|
||||
#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));
|
||||
}
|
||||
|
||||
|
||||
+13
-2
@@ -26,14 +26,18 @@
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
|
||||
const char yes = 1;
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user