AROS: add inet_pton emulation and make sure we use recv/send and not read/write
[deb_libnfs.git] / lib / socket.c
index 1ba846a1c8151893a8b2237bd8c0f06afa2faa99..9b16b1b5bc96d045c136945d1dbdd6f69f3a433b 100644 (file)
@@ -18,7 +18,6 @@
 #include "win32_compat.h"
 #else
 #include <unistd.h>
-#include <poll.h>
 #include <arpa/inet.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
+
+#ifdef AROS
+#include "aros_compat.h"
+#endif
+
+#ifdef HAVE_POLL_H
+#include <poll.h>
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <assert.h>
@@ -110,7 +118,7 @@ static int rpc_write_to_socket(struct rpc_context *rpc)
 
                total = rpc->outqueue->outdata.size;
 
-#if defined(WIN32)
+#if defined(WIN32) | defined(AROS)
                count = send(rpc->fd, rpc->outqueue->outdata.data + rpc->outqueue->written, total - rpc->outqueue->written, 0);
 #else
                count = write(rpc->fd, rpc->outqueue->outdata.data + rpc->outqueue->written, total - rpc->outqueue->written);
@@ -143,6 +151,8 @@ static int rpc_read_from_socket(struct rpc_context *rpc)
 
        assert(rpc->magic == RPC_CONTEXT_MAGIC);
 
+       assert(rpc->magic == RPC_CONTEXT_MAGIC);
+
 #if defined(WIN32)
        if (ioctlsocket(rpc->fd, FIONREAD, &available) != 0) {
 #else
@@ -192,7 +202,7 @@ static int rpc_read_from_socket(struct rpc_context *rpc)
        if (rpc->inpos < 4) {
                size = 4 - rpc->inpos;
 
-#if defined(WIN32)
+#if defined(WIN32) | defined(AROS)
                count = recv(rpc->fd, rpc->inbuf + rpc->inpos, size, 0);
 #else
                count = read(rpc->fd, rpc->inbuf + rpc->inpos, size);
@@ -232,7 +242,7 @@ static int rpc_read_from_socket(struct rpc_context *rpc)
                size = rpc->insize - rpc->inpos;
        }
 
-#if defined(WIN32)
+#if defined(WIN32) | defined(AROS)
        count = recv(rpc->fd, rpc->inbuf + rpc->inpos, size, 0);
 #else
        count = read(rpc->fd, rpc->inbuf + rpc->inpos, size);