X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=blobdiff_plain;f=sources%2FSockUtil.c;h=a2a6fcdb295665a0828db434656c3bbf2e20e812;hp=28b22defae96326ad406f723a85bea0484316bb2;hb=1bc54870307368cc8c74e07f7f4dd53498e09db0;hpb=ff8c324d1cdb252eebc1ad3c419bca5b7ac940f3 diff --git a/sources/SockUtil.c b/sources/SockUtil.c index 28b22de..a2a6fcd 100644 --- a/sources/SockUtil.c +++ b/sources/SockUtil.c @@ -195,9 +195,9 @@ int sockbind(char *host, char *serv, int prot, int type) } /**************************************************************** * - * Routine sockbind2 + * Routine sockbindopt * Return a binded socket given hostname, service, and socket type - * Issue a SO_REUSEADDR on the socket before binding. + * Issue a SO_REUSEADDR on the socket before binding on reuse value. * * Author: Simone Piccardi * Mar. 2005 @@ -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; }