From: Kurt Zeilenga Date: Wed, 4 Aug 1999 23:56:37 +0000 (+0000) Subject: Add KEEPALIVE support. X-Git-Tag: TWEB_OL_BASE~283 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3abd065219dc3b5d4e20d69957d21d3fdac6550a;p=openldap Add KEEPALIVE support. --- diff --git a/clients/gopher/go500.c b/clients/gopher/go500.c index 234d908691..9bf49a252c 100644 --- a/clients/gopher/go500.c +++ b/clients/gopher/go500.c @@ -290,17 +290,28 @@ set_socket( int port ) exit( EXIT_FAILURE ); } +#ifdef SO_REUSEADDR /* set option so clients can't keep us from coming back up */ - one = 1; + one = 1; if ( setsockopt( s, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(one) ) < 0 ) { perror( "setsockopt" ); exit( EXIT_FAILURE ); } +#endif +#ifdef SO_KEEPALIVE + /* enable keep alives */ + one = 1; + if ( setsockopt( s, SOL_SOCKET, SO_KEEPALIVE, (char *) &one, + sizeof(one) ) < 0 ) { + perror( "setsockopt" ); + exit( EXIT_FAILURE ); + } +#endif /* bind to a name */ addr.sin_family = AF_INET; - addr.sin_addr.s_addr = INADDR_ANY; + addr.sin_addr.s_addr = htonl(INADDR_ANY); addr.sin_port = htons( port ); if ( bind( s, (struct sockaddr *) &addr, sizeof(addr) ) ) { perror( "bind" ); diff --git a/clients/gopher/go500gw.c b/clients/gopher/go500gw.c index c68b3522ef..24b627f02b 100644 --- a/clients/gopher/go500gw.c +++ b/clients/gopher/go500gw.c @@ -315,17 +315,28 @@ set_socket( int port ) exit( EXIT_FAILURE ); } +#ifdef SO_REUSEADDR /* set option so clients can't keep us from coming back up */ - one = 1; + one = 1; if ( setsockopt( s, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(one) ) < 0 ) { perror( "setsockopt" ); exit( EXIT_FAILURE ); } +#endif +#ifdef SO_KEEPALIVE + /* enable keep alives */ + one = 1; + if ( setsockopt( s, SOL_SOCKET, SO_KEEPALIVE, (char *) &one, + sizeof(one) ) < 0 ) { + perror( "setsockopt" ); + exit( EXIT_FAILURE ); + } +#endif /* bind to a name */ addr.sin_family = AF_INET; - addr.sin_addr.s_addr = INADDR_ANY; + addr.sin_addr.s_addr = htonl(INADDR_ANY); addr.sin_port = htons( port ); if ( bind( s, (struct sockaddr *) &addr, sizeof(addr) ) ) { perror( "bind" );