From baec395c8ca3634bd502aa20b3610468aa9178b3 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Sun, 28 Feb 2016 20:43:43 +0100 Subject: Added support for TCP Keepalive. --- src/vmime/platforms/posix/posixSocket.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/vmime/platforms/posix/posixSocket.cpp b/src/vmime/platforms/posix/posixSocket.cpp index e13f6523..6ebd2766 100644 --- a/src/vmime/platforms/posix/posixSocket.cpp +++ b/src/vmime/platforms/posix/posixSocket.cpp @@ -138,6 +138,16 @@ void posixSocket::connect(const vmime::string& address, const vmime::port_t port continue; // try next } +#if VMIME_HAVE_SO_KEEPALIVE + + // Enable TCP Keepalive + int keepAlive_optval = 1; + socklen_t keepAlive_optlen = sizeof(keepAlive_optval); + + ::setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &keepAlive_optval, keepAlive_optlen); + +#endif // VMIME_HAVE_SO_KEEPALIVE + if (m_timeoutHandler != NULL) { ::fcntl(sock, F_SETFL, ::fcntl(sock, F_GETFL) | O_NONBLOCK); -- cgit