Import std.net.address
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.
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)-
Whether it's an IPv4 address or an IPv6 one.
-
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): IpAddressstatic method #The IPv6 address of eight 16-bit groups,
a:b:c:d:e:f:g:h. -
The address of
bytes, 4 for IPv4, or 16 for IPv6, in the order Bytes gives them. Panics for another count. -
The address
textwrites: 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. -
127.0.0.1, ::1, 0.0.0.0, ::, and 255.255.255.255.
-
::1, IPv6's loopback address.
-
0.0.0.0, IPv4's address of every interface, to listen on.
-
::, IPv6's address of every interface, to listen on.
-
255.255.255.255, IPv4's broadcast address.
-
Whether it's an IPv4 address.
-
Whether it's an IPv6 address.
-
Its 4 bytes, or 16, the most significant first.
-
127.0.0.0/8, or ::1.
-
0.0.0.0, or ::, which a socket listens on to take every address.
-
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.
-
A link's own, not routed: 169.254.0.0/16, or fe80::/10.
-
224.0.0.0/4, or ff00::/8.
-
255.255.255.255.
-
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.
-
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.
-
An IPv4 address as the IPv6 one that maps it, ::ffff:a.b.c.d, or the IPv6 one itself.
-
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.
-
Whether
acomes beforeb: an IPv4 address before an IPv6 one, and otherwise by their bytes.
Report an issue with this page or with FutureBlitz on GitHub.