Skip to content

NetAddress

[Source]

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.

class val NetAddress is
  Equatable[NetAddress val] ref

Implements


Constructors

create

[Source]

new iso create()
: NetAddress iso^

Returns


Public Functions

ip4

[Source]

true when this is an IPv4 address.

fun box ip4()
: Bool val

Returns


ip6

[Source]

true when this is an IPv6 address.

fun box ip6()
: Bool val

Returns


name

[Source]

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

  • reversedns: (DNSAuth val | None val) = None
  • servicename: Bool val = false

Returns


eq

[Source]

Two addresses are equal when they have the same family, port, host, and scope.

fun box eq(
  that: NetAddress box)
: Bool val

Parameters

Returns


host_eq

[Source]

True when the host portion matches, ignoring port and scope.

fun box host_eq(
  that: NetAddress box)
: Bool val

Parameters

Returns


length

[Source]

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.

fun box length()
: U8 val

Returns


family

[Source]

The address family.

fun box family()
: U8 val

Returns


port

[Source]

Port number in host byte order.

fun box port()
: U16 val

Returns


scope

[Source]

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.

fun box scope()
: U32 val

Returns


ipv4_addr

[Source]

IPv4 address in host byte order. Valid only when ip4() is true.

fun box ipv4_addr()
: U32 val

Returns


ipv6_addr

[Source]

IPv6 address as four 32-bit words in host byte order. Valid only when ip6() is true.

fun box ipv6_addr()
: (U32 val , U32 val , U32 val , 
    U32 val)

Returns


ne

[Source]

fun box ne(
  that: NetAddress val)
: Bool val

Parameters

Returns