aboutsummaryrefslogtreecommitdiffstats
path: root/socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'socket.c')
-rw-r--r--socket.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/socket.c b/socket.c
index 930e1b0d..5573b4ee 100644
--- a/socket.c
+++ b/socket.c
@@ -225,6 +225,12 @@ int SockTimeout(int sock, int timeout)
return err;
}
+/** Set socket to SO_KEEPALIVE. \return 0 for success. */
+int SockKeepalive(int sock) {
+ int keepalive = 1;
+ return setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &keepalive, sizeof keepalive);
+}
+
int UnixOpen(const char *path)
{
int sock = -1;
@@ -319,6 +325,9 @@ int SockOpen(const char *host, const char *service,
continue;
}
+ SockTimeout(i, mytimeout);
+ SockKeepalive(i);
+
/* Save socket descriptor.
* Used to close the socket after connect timeout. */
mailserver_socket_temp = i;