17#if defined(PROMEKI_PLATFORM_WINDOWS)
20#elif !defined(PROMEKI_PLATFORM_EMSCRIPTEN)
21# include <sys/socket.h>
22# include <netinet/in.h>
146#if !defined(PROMEKI_PLATFORM_EMSCRIPTEN)
166 return _address ==
other._address && _port ==
other._port;
171 return !(*
this ==
other);
IPv4 network address.
Definition ipv4address.h:51
static Ipv4Address loopback()
Returns the loopback address (127.0.0.1).
Definition ipv4address.h:74
static Ipv4Address any()
Returns the INADDR_ANY address (0.0.0.0).
Definition ipv4address.h:71
IPv6 network address.
Definition ipv6address.h:52
Dynamic array container wrapping std::vector.
Definition list.h:40
High-level network address that can represent IPv4, IPv6, or an unresolved hostname.
Definition networkaddress.h:64
bool isMulticast() const
Returns true if the address is a multicast address.
bool isNull() const
Returns true if no address is stored.
Definition networkaddress.h:127
bool isLoopback() const
Returns true if the address is a loopback address.
bool isIPv4() const
Returns true if this holds an IPv4 address.
Definition networkaddress.h:130
bool isIPv6() const
Returns true if this holds an IPv6 address.
Definition networkaddress.h:133
Network address with port number.
Definition socketaddress.h:50
SocketAddress(const Ipv4Address &addr, uint16_t port)
Constructs from an IPv4 address and port.
Definition socketaddress.h:100
SocketAddress()=default
Default constructor. Creates a null address with port 0.
SocketAddress(const NetworkAddress &address, uint16_t port)
Constructs from a NetworkAddress and port.
Definition socketaddress.h:92
bool isIPv4() const
Returns true if the address is IPv4.
Definition socketaddress.h:127
void setPort(uint16_t port)
Sets the port number.
Definition socketaddress.h:121
void setAddress(const NetworkAddress &address)
Sets the network address component.
Definition socketaddress.h:115
bool isLoopback() const
Returns true if the address is a loopback address.
Definition socketaddress.h:133
bool isNull() const
Returns true if no address is set and port is 0.
Definition socketaddress.h:124
bool isMulticast() const
Returns true if the address is a multicast address.
Definition socketaddress.h:136
String toString() const
Returns a "host:port" string representation.
uint16_t port() const
Returns the port number.
Definition socketaddress.h:118
static Result< SocketAddress > fromSockAddr(const struct sockaddr *addr, size_t len)
Constructs from a POSIX/Windows sockaddr structure.
static Result< SocketAddress > fromString(const String &hostPort)
Parses a "host:port" string into a SocketAddress.
bool operator!=(const SocketAddress &other) const
Inequality comparison.
Definition socketaddress.h:170
size_t toSockAddr(struct sockaddr_storage *storage) const
Fills a sockaddr_storage with this address and port.
static SocketAddress localhost(uint16_t port)
Returns localhost (127.0.0.1) with the given port.
Definition socketaddress.h:80
static SocketAddress any(uint16_t port)
Returns INADDR_ANY with the given port.
Definition socketaddress.h:71
bool operator==(const SocketAddress &other) const
Equality comparison.
Definition socketaddress.h:165
bool isIPv6() const
Returns true if the address is IPv6.
Definition socketaddress.h:130
SocketAddress(const Ipv6Address &addr, uint16_t port)
Constructs from an IPv6 address and port.
Definition socketaddress.h:108
const NetworkAddress & address() const
Returns the network address component.
Definition socketaddress.h:112
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
Formatted text I/O with encoding awareness.
Definition textstream.h:54
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19
TextStream & operator<<(TextStream &stream, const SocketAddress &addr)
Writes the socket address to the stream.