changeset 468:c670130daa80

SO_KEEPALIVE for socket
author mmj
date Tue, 15 Feb 2005 17:09:14 +1100
parents d569f7a81285
children ea8e25921b9c
files ChangeLog src/init_sockfd.c
diffstat 2 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Feb 15 10:10:02 2005 +1100
+++ b/ChangeLog	Tue Feb 15 17:09:14 2005 +1100
@@ -1,3 +1,4 @@
+ o Set SO_KEEPALIVE for our connection socket
 1.2.4
  o Spend some time making valgrind completely happy
  o Unlink totally harmless .lock files in subscribers dir.
--- a/src/init_sockfd.c	Tue Feb 15 10:10:02 2005 +1100
+++ b/src/init_sockfd.c	Tue Feb 15 17:09:14 2005 +1100
@@ -34,7 +34,7 @@
 
 void init_sockfd(int *sockfd, const char *relayhost, unsigned short port)
 {
-	int len;
+	int len, on;
 	struct sockaddr_in addr;
 
 	if (getenv("MLMMJ_TESTING")) {
@@ -56,4 +56,9 @@
 				    "exiting ... ", relayhost);
 		exit(EXIT_FAILURE);
 	}
+
+	on = 1;
+	if(setsockopt(*sockfd, SOL_SOCKET, SO_KEEPALIVE, (void *)&on,
+				sizeof(on) < 0))
+		log_error(LOG_ARGS, "Could not set SO_KEEPALIVE");
 }