ZDR: New builtin replacement for RPC/XDR called ZDR
[deb_libnfs.git] / lib / socket.c
index 0f12697388779cd3f819bcf39c22227c0ddf225d..360e511c1fb68454fb0dcfc26c290994b7b826a3 100644 (file)
@@ -33,8 +33,6 @@
 #include <fcntl.h>
 #include <string.h>
 #include <errno.h>
-#include <rpc/rpc.h>
-#include <rpc/xdr.h>
 #ifdef HAVE_SYS_FILIO_H
 #include <sys/filio.h>
 #endif
@@ -42,6 +40,7 @@
 #include <sys/sockio.h>
 #endif
 #include <sys/types.h>
+#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;
        }