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 # ifdef OF_HAVE_THREADS 61 # define SocketBase ((struct Library *)OFTLSKeyGet(_OFSocketBaseKey)) 63 # define ISocket ((struct SocketIFace *)OFTLSKeyGet(_OFSocketInterfaceKey)) 67 typedef uint32_t in_addr_t;
69 #elif !defined(OF_WINDOWS) && !defined(OF_WII) 70 # define closesocket(sock) close(sock) 71 # define ioctlsocket(...) ioctl(__VA_ARGS__) 75 # define accept(sock, addr, addrlen) net_accept(sock, addr, addrlen) 76 # define bind(sock, addr, addrlen) net_bind(sock, addr, addrlen) 77 # define closesocket(sock) net_close(sock) 78 # define connect(sock, addr, addrlen) \ 79 net_connect(sock, (struct sockaddr *)addr, addrlen) 80 # define fcntl(fd, cmd, flags) net_fcntl(fd, cmd, flags) 82 # define hstrerror(err) "unknown (no hstrerror)" 83 # define ioctlsocket(...) net_ioctl(__VA_ARGS__) 84 # define listen(sock, backlog) net_listen(sock, backlog) 85 # define poll(fds, nfds, timeout) net_poll(fds, nfds, timeout) 86 # define recv(sock, buf, len, flags) net_recv(sock, buf, len, flags) 87 # define recvfrom(sock, buf, len, flags, addr, addrlen) \ 88 net_recvfrom(sock, buf, len, flags, addr, addrlen) 89 # define select(nfds, readfds, writefds, errorfds, timeout) \ 90 net_select(nfds, readfds, writefds, errorfds, timeout) 91 # define send(sock, buf, len, flags) net_send(sock, buf, len, flags) 92 # define sendto(sock, buf, len, flags, addr, addrlen) \ 93 net_sendto(sock, buf, len, flags, (struct sockaddr *)(addr), addrlen) 94 # define setsockopt(sock, level, name, value, len) \ 95 net_setsockopt(sock, level, name, value, len) 96 # define socket(domain, type, proto) net_socket(domain, type, proto) 97 typedef u32 in_addr_t;
101 OF_ASSUME_NONNULL_BEGIN
106 extern bool _OFSocketInit(
void) OF_VISIBILITY_INTERNAL;
107 #if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) 108 extern void _OFSocketDeinit(
void) OF_VISIBILITY_INTERNAL;
110 extern int _OFSocketErrNo(
void) OF_VISIBILITY_INTERNAL;
111 #if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) 112 extern int _OFGetSockName(OFSocketHandle sock,
struct sockaddr *restrict addr,
113 socklen_t *restrict addrLen) OF_VISIBILITY_INTERNAL;
116 #if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) 117 extern OFTLSKey _OFSocketBaseKey OF_VISIBILITY_INTERNAL;
119 extern OFTLSKey _OFSocketInterfaceKey OF_VISIBILITY_INTERNAL;
126 OF_ASSUME_NONNULL_END