16 #include "objfw-defs.h"
18 #ifndef OF_HAVE_SOCKETS
19 # error No sockets available!
26 #ifdef OF_HAVE_SYS_SOCKET_H
27 # include <sys/socket.h>
29 #ifdef OF_HAVE_NETINET_IN_H
30 # include <netinet/in.h>
32 #ifdef OF_HAVE_NETINET_TCP_H
33 # include <netinet/tcp.h>
35 #ifdef OF_HAVE_NETINET_SCTP_H
36 # include <netinet/sctp.h>
38 #ifdef OF_HAVE_NETIPX_IPX_H
39 # include <netipx/ipx.h>
46 # include <ws2tcpip.h>
63 #if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS)
67 OF_ASSUME_NONNULL_BEGIN
70 typedef int of_socket_t;
72 typedef SOCKET of_socket_t;
76 typedef u8 sa_family_t;
80 typedef long socklen_t;
81 typedef u_char sa_family_t;
82 typedef u_short in_port_t;
102 struct sockaddr_in6 {
103 sa_family_t sin6_family;
105 uint32_t sin6_flowinfo;
109 uint32_t sin6_scope_id;
114 # define IPX_NODE_LEN 6
115 struct sockaddr_ipx {
116 sa_family_t sipx_family;
117 uint32_t sipx_network;
118 unsigned char sipx_node[IPX_NODE_LEN];
124 # define IPX_NODE_LEN 6
125 # define sipx_family sa_family
126 # define sipx_network sa_netnum
127 # define sipx_node sa_nodenum
128 # define sipx_port sa_socket
146 struct sockaddr sockaddr;
147 struct sockaddr_in in;
148 struct sockaddr_in6 in6;
149 struct sockaddr_ipx ipx;
196 const unsigned char node[_Nonnull IPX_NODE_LEN], uint32_t network,
276 const unsigned char node[_Nonnull IPX_NODE_LEN]);
286 unsigned char node[_Nonnull IPX_NODE_LEN]);
288 extern bool of_socket_init(
void);
289 #if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) && !defined(OF_MORPHOS)
290 extern void of_socket_deinit(
void);
292 extern int of_socket_errno(
void);
293 #if !defined(OF_WII) && !defined(OF_NINTENDO_3DS)
294 extern int of_getsockname(of_socket_t sock,
struct sockaddr *restrict addr,
295 socklen_t *restrict addrLen);
298 #if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) && !defined(OF_MORPHOS)
299 extern of_tlskey_t of_socket_base_key;
301 extern of_tlskey_t of_socket_interface_key;
308 OF_ASSUME_NONNULL_END
A class for handling strings.
Definition: OFString.h:132
of_socket_address_family_t
A socket address family.
Definition: socket.h:88
@ OF_SOCKET_ADDRESS_FAMILY_UNKNOWN
Definition: socket.h:90
@ OF_SOCKET_ADDRESS_FAMILY_IPV6
Definition: socket.h:94
@ OF_SOCKET_ADDRESS_FAMILY_IPX
Definition: socket.h:96
@ OF_SOCKET_ADDRESS_FAMILY_IPV4
Definition: socket.h:92
@ OF_SOCKET_ADDRESS_FAMILY_ANY
Definition: socket.h:98
of_socket_address_t of_socket_address_parse_ip(OFString *IP, uint16_t port)
Parses the specified IP and port into an of_socket_address_t.
Definition: socket.m:505
unsigned long of_socket_address_hash(const of_socket_address_t *_Nonnull address)
Returns the hash for the specified of_socket_address_t.
void of_socket_address_set_ipx_node(of_socket_address_t *_Nonnull address, const unsigned char node[_Nonnull IPX_NODE_LEN])
Sets the IPX node of the specified of_socket_address_t.
void of_socket_address_set_ipx_network(of_socket_address_t *_Nonnull address, uint32_t network)
Sets the IPX network of the specified of_socket_address_t.
of_socket_address_t of_socket_address_ipx(const unsigned char node[_Nonnull IPX_NODE_LEN], uint32_t network, uint16_t port)
Creates an IPX address for the specified network, node and port.
uint16_t of_socket_address_get_port(const of_socket_address_t *_Nonnull address)
Returns the port of the specified of_socket_address_t, independent of the address family used.
bool of_socket_address_equal(const of_socket_address_t *_Nonnull address1, const of_socket_address_t *_Nonnull address2)
Compares two of_socket_address_t for equality.
void of_socket_address_set_port(of_socket_address_t *_Nonnull address, uint16_t port)
Sets the port of the specified of_socket_address_t, independent of the address family used.
of_socket_address_t of_socket_address_parse_ipv6(OFString *IP, uint16_t port)
Parses the specified IPv6 and port into an of_socket_address_t.
Definition: socket.m:426
void of_socket_address_get_ipx_node(const of_socket_address_t *_Nonnull address, unsigned char node[_Nonnull IPX_NODE_LEN])
Gets the IPX node of the specified of_socket_address_t.
OFString *_Nonnull of_socket_address_ip_string(const of_socket_address_t *_Nonnull address, uint16_t *_Nullable port)
Converts the specified of_socket_address_t to an IP string and port.
of_socket_address_t of_socket_address_parse_ipv4(OFString *IP, uint16_t port)
Parses the specified IPv4 and port into an of_socket_address_t.
Definition: socket.m:352
uint32_t of_socket_address_get_ipx_network(const of_socket_address_t *_Nonnull address)
Returns the IPX network of the specified of_socket_address_t.
A struct which represents a host / port pair for a socket.
Definition: socket.h:136