diff --git a/src/includes.h b/src/includes.h index 005239b..6768f00 100644 --- a/src/includes.h +++ b/src/includes.h @@ -25,6 +25,7 @@ #include #include #include +#include #include // forward declarations diff --git a/src/tcpresolver.h b/src/tcpresolver.h index 19c1938..e16d626 100644 --- a/src/tcpresolver.h +++ b/src/tcpresolver.h @@ -110,7 +110,17 @@ private: } // connection succeeded, mark socket as non-blocking - if (_socket >= 0) fcntl(_socket, F_SETFL, O_NONBLOCK); + if (_socket >= 0) + { + // turn socket into a non-blocking socket + fcntl(_socket, F_SETFL, O_NONBLOCK); + + // we want to enable "nodelay" on sockets (otherwise all send operations are s-l-o-w + int optval = 1; + + // set the option + setsockopt(_socket, IPPROTO_TCP, TCP_NODELAY, &optval, sizeof(int)); + } } catch (const std::runtime_error &error) {