- linux, osx, and ios need rpc/rpc.h includede before rpc/xdr.h
[deb_libnfs.git] / lib / socket.c
index 1de64b6b454a42a937bea4fb0f05008e023f46dc..4701685591793c67f2811aa0b3858c7aa87aef66 100644 (file)
 */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <poll.h>
 #include <string.h>
 #include <errno.h>
+#include <rpc/rpc.h>
 #include <rpc/xdr.h>
 #include <arpa/inet.h>
 #include <sys/ioctl.h>
@@ -251,8 +253,11 @@ int rpc_connect_async(struct rpc_context *rpc, const char *server, int port, rpc
 
        switch (s.ss_family) {
        case AF_INET:
-               rpc->fd = socket(AF_INET, SOCK_STREAM, 0);
                socksize = sizeof(struct sockaddr_in);
+#ifdef HAVE_SOCK_SIN_LEN
+               sin->sin_len = socksize;
+#endif
+               rpc->fd = socket(AF_INET, SOCK_STREAM, 0);
                break;
        }