diff options
author | Matthias Andree <matthias.andree@gmx.de> | 2011-05-13 13:15:03 +0200 |
---|---|---|
committer | Matthias Andree <matthias.andree@gmx.de> | 2011-05-13 13:15:03 +0200 |
commit | c7abefc668b1351ded4a58b93f78e84c62be1684 (patch) | |
tree | 9c65372906df402d87115dcab3d64aa438897c77 /socket.c | |
parent | 09d71d6dc7721dbc9c802405407ee9701d306993 (diff) | |
download | fetchmail-c7abefc668b1351ded4a58b93f78e84c62be1684.tar.gz fetchmail-c7abefc668b1351ded4a58b93f78e84c62be1684.tar.bz2 fetchmail-c7abefc668b1351ded4a58b93f78e84c62be1684.zip |
SockOpen(): set SO_KEEPALIVE.
Diffstat (limited to 'socket.c')
-rw-r--r-- | socket.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -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; |