SOCKET: Use recv/send for all socket io on all platforms
[deb_libnfs.git] / lib / socket.c
index 1ba846a1c8151893a8b2237bd8c0f06afa2faa99..6f626529be9a2c3d6c7b982a648e9edf806d2e2d 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,11 +118,7 @@ static int rpc_write_to_socket(struct rpc_context *rpc)
 
                total = rpc->outqueue->outdata.size;
 
-#if defined(WIN32)
                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);
-#endif
                if (count == -1) {
                        if (errno == EAGAIN || errno == EWOULDBLOCK) {
                                return 0;
@@ -143,6 +147,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,11 +198,7 @@ static int rpc_read_from_socket(struct rpc_context *rpc)
        if (rpc->inpos < 4) {
                size = 4 - rpc->inpos;
 
-#if defined(WIN32)
                count = recv(rpc->fd, rpc->inbuf + rpc->inpos, size, 0);
-#else
-               count = read(rpc->fd, rpc->inbuf + rpc->inpos, size);
-#endif
                if (count == -1) {
                        if (errno == EINTR) {
                                return 0;
@@ -232,11 +234,7 @@ static int rpc_read_from_socket(struct rpc_context *rpc)
                size = rpc->insize - rpc->inpos;
        }
 
-#if defined(WIN32)
        count = recv(rpc->fd, rpc->inbuf + rpc->inpos, size, 0);
-#else
-       count = read(rpc->fd, rpc->inbuf + rpc->inpos, size);
-#endif
        if (count == -1) {
                if (errno == EINTR) {
                        return 0;