Skip to content

Commit e97ae19

Browse files
add TCP_NODELAY to connections to speed up SSL handshakes (#1403)
1 parent bbfdd9b commit e97ae19

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/dpp/sslconnection.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
/* Anything other than Windows (e.g. sane OSes) */
3131
#include <sys/socket.h>
3232
#include <unistd.h>
33+
#include <netinet/tcp.h>
3334
#endif
3435
#include <csignal>
3536
#include <sys/types.h>
@@ -106,6 +107,7 @@ bool close_socket(dpp::socket sfd)
106107

107108
bool set_nonblocking(dpp::socket sockfd, bool non_blocking)
108109
{
110+
const int enable{1};
109111
#ifdef _WIN32
110112
u_long mode = non_blocking ? 1 : 0;
111113
int result = ioctlsocket(sockfd, FIONBIO, &mode);
@@ -123,6 +125,7 @@ bool set_nonblocking(dpp::socket sockfd, bool non_blocking)
123125
return false;
124126
}
125127
#endif
128+
setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast<const char*>(&enable), sizeof(int));
126129
return true;
127130
}
128131

0 commit comments

Comments
 (0)