22#include "unistd_wrapper.h"
24#ifdef HAVE_ARPA_INET_H
25# include <arpa/inet.h>
34# define INADDR_NONE ((in_addr_t)-1)
46# define SOCK_CLOEXEC 0
49#if defined(OF_AMIGAOS)
51# include <proto/socket.h>
53# include <proto/bsdsocket.h>
55# include <sys/filio.h>
56# define closesocket(sock) CloseSocket(sock)
57# define ioctlsocket(fd, req, arg) IoctlSocket(fd, req, arg)
58# define hstrerror(err) "unknown (no hstrerror)"
59# define SOCKET_ERROR -1
60# if defined(OF_HAVE_THREADS) && !defined(OF_MORPHOS)
61# define SocketBase ((struct Library *)OFTLSKeyGet(_OFSocketBaseKey))
63# define ISocket ((struct SocketIFace *)OFTLSKeyGet(_OFSocketInterfaceKey))
67typedef uint32_t in_addr_t;
69#elif !defined(OF_WINDOWS) && !defined(OF_WII)
70# define closesocket(sock) close(sock)
74# define accept(sock, addr, addrlen) net_accept(sock, addr, addrlen)
75# define bind(sock, addr, addrlen) net_bind(sock, addr, addrlen)
76# define closesocket(sock) net_close(sock)
77# define connect(sock, addr, addrlen) \
78 net_connect(sock, (struct sockaddr *)addr, addrlen)
79# define fcntl(fd, cmd, flags) net_fcntl(fd, cmd, flags)
81# define hstrerror(err) "unknown (no hstrerror)"
82# define listen(sock, backlog) net_listen(sock, backlog)
83# define poll(fds, nfds, timeout) net_poll(fds, nfds, timeout)
84# define recv(sock, buf, len, flags) net_recv(sock, buf, len, flags)
85# define recvfrom(sock, buf, len, flags, addr, addrlen) \
86 net_recvfrom(sock, buf, len, flags, addr, addrlen)
87# define select(nfds, readfds, writefds, errorfds, timeout) \
88 net_select(nfds, readfds, writefds, errorfds, timeout)
89# define send(sock, buf, len, flags) net_send(sock, buf, len, flags)
90# define sendto(sock, buf, len, flags, addr, addrlen) \
91 net_sendto(sock, buf, len, flags, (struct sockaddr *)(addr), addrlen)
92# define setsockopt(sock, level, name, value, len) \
93 net_setsockopt(sock, level, name, value, len)
94# define socket(domain, type, proto) net_socket(domain, type, proto)
99OF_ASSUME_NONNULL_BEGIN
104extern bool _OFSocketInit(
void) OF_VISIBILITY_HIDDEN;
105#if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) && !defined(OF_MORPHOS)
106extern void _OFSocketDeinit(
void) OF_VISIBILITY_HIDDEN;
108extern int _OFSocketErrNo(
void) OF_VISIBILITY_HIDDEN;
109#if !defined(OF_WII) && !defined(OF_NINTENDO_3DS)
110extern int _OFGetSockName(OFSocketHandle sock,
struct sockaddr *restrict addr,
111 socklen_t *restrict addrLen) OF_VISIBILITY_HIDDEN;
114#if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) && !defined(OF_MORPHOS)
115extern OFTLSKey _OFSocketBaseKey OF_VISIBILITY_HIDDEN;
117extern OFTLSKey _OFSocketInterfaceKey OF_VISIBILITY_HIDDEN;