X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fsocket.c;h=360e511c1fb68454fb0dcfc26c290994b7b826a3;hb=763cd6e3e2bbb6906186e7ed6a86660276b596b7;hp=0f12697388779cd3f819bcf39c22227c0ddf225d;hpb=183451cff566ac49ab872821e458e57b90e72710;p=deb_libnfs.git diff --git a/lib/socket.c b/lib/socket.c index 0f12697..360e511 100644 --- a/lib/socket.c +++ b/lib/socket.c @@ -33,8 +33,6 @@ #include #include #include -#include -#include #ifdef HAVE_SYS_FILIO_H #include #endif @@ -42,6 +40,7 @@ #include #endif #include +#include "libnfs-zdr.h" #include "libnfs.h" #include "libnfs-raw.h" #include "libnfs-private.h" @@ -381,14 +380,17 @@ static int rpc_connect_sockaddr_async(struct rpc_context *rpc, struct sockaddr_s * to make the executable able to bind to a system port. */ if (1) { - int port; + static int port = 200; + int i; int one = 1; setsockopt(rpc->fd, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(one)); - for (port = 200; port < 500; port++) { + for (i = 0; i < 500; i++) { struct sockaddr_in sin; + if(++port > 700) port = 200; + memset(&sin, 0, sizeof(sin)); sin.sin_port = htons(port); sin.sin_family = AF_INET; @@ -411,7 +413,7 @@ static int rpc_connect_sockaddr_async(struct rpc_context *rpc, struct sockaddr_s if (connect(rpc->fd, (struct sockaddr *)s, socksize) != 0 && errno != EINPROGRESS) #endif { - rpc_set_error(rpc, "connect() to server failed"); + rpc_set_error(rpc, "connect() to server failed. %s(%d)", strerror(errno), errno); return -1; }