Skip to content
FutureBlitz

    Install

    Import std.net.address

    IpAddress

    std.net.address

    struct

    Public Struct IpAddress Implements Hashable, Comparable, Printable

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

    Examples

    Local home = IpAddress.Parse("192.168.1.20")
    Expect(home == IpAddress.V4(192, 168, 1, 20))
    Expect(home?.IsPrivate == True && home?.IsV4 == True)
    Expect(IpAddress.Parse("::1") == IpAddress.LoopbackV6)
    Expect(IpAddress.Parse("300.1.1.1") == Null)

    std/net/address.fb, line 32

    • 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: an IPv4 address before an IPv6 one, and otherwise by their bytes.

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