aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2016-02-28 19:43:43 +0000
committerVincent Richard <[email protected]>2016-02-28 19:43:43 +0000
commitbaec395c8ca3634bd502aa20b3610468aa9178b3 (patch)
tree486e42ee87f8653b285210911eb5815fb6ebab70 /src
parentMerge branch 'master' of https://github.com/kisli/vmime (diff)
downloadvmime-baec395c8ca3634bd502aa20b3610468aa9178b3.tar.gz
vmime-baec395c8ca3634bd502aa20b3610468aa9178b3.zip
Added support for TCP Keepalive.
Diffstat (limited to 'src')
-rw-r--r--src/vmime/platforms/posix/posixSocket.cpp10
1 files changed, 10 insertions, 0 deletions
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);