NetAddress¶
An IPv4 or IPv6 socket address, modelled after sockaddr_storage. The
_family field indicates which kind; the _addr field is either the IPv4
address or the IPv6 flow info, and _addr1–_addr4 are the IPv6 address
(invalid for IPv4). All address and port fields are in network byte order;
_scope is in host byte order.
Call name() to get the address and port as strings.
Implements¶
- Equatable[NetAddress val] ref
Constructors¶
create¶
Returns¶
- NetAddress iso^
Public Functions¶
ip4¶
true when this is an IPv4 address.
Returns¶
- Bool val
ip6¶
true when this is an IPv6 address.
Returns¶
- Bool val
name¶
The host and service as strings. When reversedns is a DNSAuth, a DNS
lookup returns the hostname; when it is None the plain IP address is
returned. When servicename is true the port is translated to its
service name (e.g. port 80 becomes "http"). Raises an error when reverse
DNS is requested and no hostname is found. Uses getnameinfo internally.
fun box name(
reversedns: (DNSAuth val | None val) = None,
servicename: Bool val = false)
: (String val , String val) ?
Parameters¶
Returns¶
eq¶
Two addresses are equal when they have the same family, port, host, and scope.
Parameters¶
- that: NetAddress box
Returns¶
- Bool val
host_eq¶
True when the host portion matches, ignoring port and scope.
Parameters¶
- that: NetAddress box
Returns¶
- Bool val
length¶
On platforms whose sockaddr includes a length field (macOS, FreeBSD),
returns that length. On Linux and Windows, returns the size of
sockaddr_in or sockaddr_in6.
Returns¶
- U8 val
family¶
The address family.
Returns¶
- U8 val
port¶
Port number in host byte order.
Returns¶
- U16 val
scope¶
IPv6 scope zone identifier (sin6_scope_id). For link-local and scoped
multicast addresses, the interface index (e.g. fe80::1%eth0). 0 for
global addresses; invalid for IPv4.
Returns¶
- U32 val
ipv4_addr¶
IPv4 address in host byte order. Valid only when ip4() is true.
Returns¶
- U32 val
ipv6_addr¶
IPv6 address as four 32-bit words in host byte order. Valid only when
ip6() is true.
Returns¶
ne¶
Parameters¶
- that: NetAddress val
Returns¶
- Bool val