Risistemate le trattazioni delle opzioni SO_KEEPALIVE e SO_REUSEADDR, con
[gapil.git] / sources / SockUtil.c
index 28b22defae96326ad406f723a85bea0484316bb2..8b3fef219143d48543cb0e2dd49b79651efb8840 100644 (file)
@@ -205,12 +205,11 @@ int sockbind(char *host, char *serv, int prot, int type)
  * $Id$ 
  *
  ****************************************************************/
-int sockbind2(char *host, char *serv, int prot, int type) 
+int sockbindopt(char *host, char *serv, int prot, int type, int reuse) 
 {
     struct addrinfo hint, *addr, *save;
     int res;
     int sock;
-    int opt=1;
     char buf[INET6_ADDRSTRLEN];
     /* initialize hint structure */
     memset(&hint, 0, sizeof(struct addrinfo)); 
@@ -240,7 +239,8 @@ int sockbind2(char *host, char *serv, int prot, int type)
            }
        }
        /* connect the socket */
-       if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt))) {
+       if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, 
+                      &reuse, sizeof(reuse))) {
            printf("error on socket options\n");
            return -1;
        }