Set TCP_NODELAY on connections (#5558)

* Set TCP_NODELAY on connections

Signed-off-by: Mike Jagdis <mjagdis@eris-associates.co.uk>

* Windows wants a char *  not a void * :-(

Signed-off-by: Mike Jagdis <mjagdis@eris-associates.co.uk>

* And clang objects to old style casts

Signed-off-by: Mike Jagdis <mjagdis@eris-associates.co.uk>

---------

Signed-off-by: Mike Jagdis <mjagdis@eris-associates.co.uk>
This commit is contained in:
mjagdis 2024-05-31 12:04:51 +01:00 committed by GitHub
parent 64e97c8d16
commit a66a67c2ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 0 deletions

View File

@ -98,6 +98,7 @@
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/socket.h>
#include <unistd.h>
#endif

View File

@ -328,6 +328,9 @@ void cServerHandleImpl::Callback(evconnlistener * a_Listener, evutil_socket_t a_
return;
}
const int one = 1;
setsockopt(a_Socket, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast<const char *>(&one), sizeof(one));
// Create a new cTCPLink for the incoming connection:
cTCPLinkImplPtr Link = std::make_shared<cTCPLinkImpl>(a_Socket, LinkCallbacks, Self->m_SelfPtr, a_Addr, static_cast<socklen_t>(a_Len));
{