summaryrefslogtreecommitdiff
path: root/src/socket
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2025-01-01 15:44:14 -0500
committerAndrew Opalach <andrew@akon.city> 2025-01-01 15:44:14 -0500
commit8b5c569b53f9287e8b6c84e4402ec6f796e4cb6b (patch)
tree1603adacfcc46c5489203d1054467d3b42353aaa /src/socket
parentbe4eb3831a2e5b44fb6e4c2d077e3c07edf6b776 (diff)
downloadlibnaunet-8b5c569b53f9287e8b6c84e4402ec6f796e4cb6b.tar.gz
libnaunet-8b5c569b53f9287e8b6c84e4402ec6f796e4cb6b.tar.bz2
libnaunet-8b5c569b53f9287e8b6c84e4402ec6f796e4cb6b.zip
Add direct (same process) mode for packet stream
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/socket')
-rw-r--r--src/socket/socket.h26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/socket/socket.h b/src/socket/socket.h
index 6b53812..bb1fa3f 100644
--- a/src/socket/socket.h
+++ b/src/socket/socket.h
@@ -3,7 +3,9 @@
#include <al/types.h>
#include <al/str.h>
-#ifndef _WIN32
+#ifdef NAUNET_ON_WINDOWS
+#include "../winwrap.h"
+#else
#include <unistd.h>
#include <sys/un.h>
#include <sys/eventfd.h>
@@ -12,8 +14,6 @@
#include <netinet/tcp.h>
#include <netdb.h>
#include <poll.h>
-#else
-#include "../winwrap.h"
#endif
enum {
@@ -29,23 +29,23 @@ enum {
struct nn_socket {
u8 type;
-#ifndef _WIN32
- s32 fd;
- struct addrinfo *addrinfo;
- struct sockaddr_un addr_un;
-#else
+#ifdef NAUNET_ON_WINDOWS
SOCKET fd;
s32 internal_fd;
SOCKADDR_IN addr_in;
+#else
+ s32 fd;
+ struct addrinfo *addrinfo;
+ struct sockaddr_un addr_un;
#endif
};
-#ifndef _WIN32
-#define nn_read read
-#define nn_write write
-#else
+#ifdef NAUNET_ON_WINDOWS
#define nn_read _read
#define nn_write _write
+#else
+#define nn_read read
+#define nn_write write
#endif
#define nn_htons htons
@@ -53,7 +53,7 @@ struct nn_socket {
#define nn_ntohs ntohs
#define nn_ntohl ntohl
-#ifndef _WIN32 // Posix-only helpers.
+#ifndef NAUNET_ON_WINDOWS // Posix-only helpers.
#define nn_pollfd pollfd
#define nn_nfds nfds_t
void nn_fd_set_blocking(s32 fd, bool blocking);