X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=clients%2Fgopher%2Fgo500gw.c;h=c1c5ab4a9ef47c556e3823f66d3ce195aedeb13f;hb=403f4479bc9f9a864122d4aeecf7284408918302;hp=c68b3522ef6344b56bfa0d4a158a055a4f1262e2;hpb=df8f7cbb9b79be3be9205d116d1dd0b263d6861a;p=openldap diff --git a/clients/gopher/go500gw.c b/clients/gopher/go500gw.c index c68b3522ef..c1c5ab4a9e 100644 --- a/clients/gopher/go500gw.c +++ b/clients/gopher/go500gw.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright (c) 1990 Regents of the University of Michigan. * All rights reserved. @@ -63,10 +64,10 @@ char *templatefile = TEMPLATEFILE; char *friendlyfile = FRIENDLYFILE; int rdncount = GO500GW_RDNCOUNT; -static void usage ( char *name ); +static void usage ( char *name ) LDAP_GCCATTR((noreturn)); static int set_socket (int port); static RETSIGTYPE wait4child(int sig); -static void do_queries (int s); +static void do_queries (int s) LDAP_GCCATTR((noreturn)); static char *pick_oc ( char **oclist ); static int isnonleaf ( LDAP *ld, char **oclist, char *dn ); static void do_menu (LDAP *ld, FILE *fp, char *dn); @@ -315,17 +316,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" );