]> git.sur5r.net Git - openldap/commitdiff
Add KEEPALIVE support.
authorKurt Zeilenga <kurt@openldap.org>
Wed, 4 Aug 1999 23:56:37 +0000 (23:56 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 4 Aug 1999 23:56:37 +0000 (23:56 +0000)
clients/gopher/go500.c
clients/gopher/go500gw.c

index 234d908691a381466da3285c115f2ae56801d18f..9bf49a252c5ace7b760b13e62698405c6e9861ef 100644 (file)
@@ -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" );
index c68b3522ef6344b56bfa0d4a158a055a4f1262e2..24b627f02b97368fcee7e160529f8d6e7b6e4fd1 100644 (file)
@@ -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" );