struct NetworkAddress

Represents an IPv4 or IPv6 network address.

Public

Constructors

NetworkAddress

NetworkAddress() = default

Creates a null address.

NetworkAddress

NetworkAddress(const char *address)

Creates the system address from a printable IP string, with an optional port component.

address
Null-terminated string such as "192.0.0.1" or "2001:db8:63b3:1::3490". The string can optionally also contain a port component, delimited using "|", such as "192.0.0.1|1234".

NetworkAddress

NetworkAddress(const char *ip, u16 port)

Creates the system address from a printable IP string, with a separately specified port component.

ip
Null-terminated string such as "192.0.0.1" or "2001:db8:63b3:1::3490".
port
Port in range [0, 65535].

Methods

ToString

String ToString(bool withPort = false) const

Converts the network address into printable string, with an optional port component.

withPort
If true the returned string will contain a port component delimited with "|" after the IP string. For example, "192.0.0.1|1234".

Returns: Printable IP string, such as "192.0.0.1" or "2001:db8:63b3:1::3490". If is true the string will also include a port component.

CompareIP

bool CompareIP(const NetworkAddress &other) const

Compares the IP portion of a network address with another address (ignoring port).

other
Other address to compare with.

Returns: True if the IP addresses match, false otherwise.

Fields

IP

u8[16] IP

Port

u16 Port

IPType

IP6FlowInfo

u64 IP6FlowInfo

IP6ScopeId

u64 IP6ScopeId

Operators

operator=

NetworkAddress &operator=(const NetworkAddress &rhs)

operator==

bool operator==(const NetworkAddress &rhs) const

operator!=

bool operator!=(const NetworkAddress &rhs) const