Skip to content
FutureBlitz

    Install

    Import std.net.address

    std.net.address

    std.net's addresses: IpAddress, an IPv4 or IPv6 address, read from and written as its text, with what kind of address it is, and SocketAddress, one with a port, which sockets connect to and listen on.

    std/net/address.fb

    Types

    IpFamily enum

    Public Enum IpFamily

    Which version of IP an address is.

    std/net/address.fb, line 12

    • V4 enum member #

      IPv4, with 4-byte addresses.

    • V6 enum member #

      IPv6, with 16-byte addresses.

    IpAddress struct

    Public Struct IpAddress Implements Hashable, Comparable, Printable

    An IPv4 or IPv6 address. Addresses compare by family, IPv4 first, then as their bytes do.

    std/net/address.fb, line 20

    • Public ReadOnly Field Family: IpFamily field #

      Whether it's an IPv4 address or an IPv6 one.

    • Public Static Method V4(a: UInt8, b: UInt8, c: UInt8, d: UInt8): IpAddress static method #

      The IPv4 address a.b.c.d.

    • Public Static Method V6(a: UInt16, b: UInt16, c: UInt16, d: UInt16, e: UInt16, f: UInt16, g: UInt16, h: UInt16): IpAddress static method #

      The IPv6 address of eight 16-bit groups, a:b:c:d:e:f:g:h.

    • @PanicsAtCaller Public Static Method FromBytes(bytes: UInt8[]): IpAddress static method #

      The address of bytes, 4 for IPv4, or 16 for IPv6, in the order Bytes gives them. Panics for another count.

    • Public Static Method Parse(text: String): IpAddress? static method #

      The address text writes: IPv4's four decimal numbers from 0 to 255 with dots between, with no leading zeros, or IPv6's eight groups of up to four hex digits, in either case, with colons between, where one :: can stand for groups of zeros and the last two can be IPv4's, as RFC 4291 has them. Null for anything else, a zone like "%eth0" too.

    • Public Static Property Loopback: IpAddress property #

      127.0.0.1, ::1, 0.0.0.0, ::, and 255.255.255.255.

    • Public Static Property LoopbackV6: IpAddress property #

      ::1, IPv6's loopback address.

    • Public Static Property Any: IpAddress property #

      0.0.0.0, IPv4's address of every interface, to listen on.

    • Public Static Property AnyV6: IpAddress property #

      ::, IPv6's address of every interface, to listen on.

    • Public Static Property Broadcast: IpAddress property #

      255.255.255.255, IPv4's broadcast address.

    • Public Property IsV4: Bool property #

      Whether it's an IPv4 address.

    • Public Property IsV6: Bool property #

      Whether it's an IPv6 address.

    • Public Property Bytes: UInt8[] property #

      Its 4 bytes, or 16, the most significant first.

    • Public Property IsLoopback: Bool property #

      127.0.0.0/8, or ::1.

    • Public Property IsUnspecified: Bool property #

      0.0.0.0, or ::, which a socket listens on to take every address.

    • Public Property IsPrivate: Bool property #

      A private network's: 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16, as RFC 1918 has them, or IPv6's unique local fc00::/7, RFC 4193's.

    • Public Property IsLinkLocal: Bool property #

      A link's own, not routed: 169.254.0.0/16, or fe80::/10.

    • Public Property IsMulticast: Bool property #

      224.0.0.0/4, or ff00::/8.

    • Public Property IsBroadcast: Bool property #

      255.255.255.255.

    • Public Property IsDocumentation: Bool property #

      For examples, as RFC 5737, RFC 3849, and RFC 9637 set them aside: 192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24, 2001:db8::/32, and 3fff::/20.

    • Public Method ToV4(): IpAddress? method #

      The IPv4 address an IPv4-mapped IPv6 one stands for, ::ffff:a.b.c.d, the IPv4 one itself, or Null for another IPv6 one.

    • Public Method ToV6(): IpAddress method #

      An IPv4 address as the IPv6 one that maps it, ::ffff:a.b.c.d, or the IPv6 one itself.

    • Public Method ToString(): String method #

      IPv4's dotted text, or IPv6's as RFC 5952 writes it: lowercase, without leading zeros, with :: for the longest run of two zero groups or more, the first of equal ones, and an IPv4-mapped address's last two groups as IPv4's text.

    • Operator <(a: IpAddress, b: IpAddress): Bool operator #

      Whether a comes before b.

      Doc from std.core.interfaces.Comparable.Operator<.

    SocketAddress struct

    Public Struct SocketAddress Implements Hashable, Comparable, Printable

    An IpAddress with a port: where a socket connects to or listens on. An IPv6 one can have a scope, its zone's index, for a link-local address, as in [fe80::1%3]:80.

    std/net/address.fb, line 251

    • Public ReadOnly Field Address: IpAddress field #

      Its address.

    • Public ReadOnly Field Port: UInt16 field #

      Its port.

    • Public ReadOnly Field ScopeId: UInt32 field #

      An IPv6 link-local address's scope, its zone's index, or 0 for none.

    • @PanicsAtCaller Public New(address: IpAddress, port: UInt16, scopeId: UInt32 = 0) constructor #

      Panics for a ScopeId on an IPv4 address, which has none.

    • Public Static Method Parse(text: String): SocketAddress? static method #

      The address text writes as ToString does: an IPv4 address and its port, as in 127.0.0.1:80, or an IPv6 one in brackets, with its scope's number after a %, as in [::1]:80 and [fe80::1%3]:80. Null for anything else, a scope's name like %eth0 too.

    • Public Property Family: IpFamily property #

      Its address's family.

    • Public Method ToString(): String method #

      Its text, as a string interpolation like "{value}" shows it.

      Doc from std.core.interfaces.Printable.ToString.

    • Operator <(a: SocketAddress, b: SocketAddress): Bool operator #

      Whether a comes before b.

      Doc from std.core.interfaces.Comparable.Operator<.

    Report an issue with this page or with FutureBlitz on GitHub.