ipv4Address
ipv4Address(num: Integer) : IpAddress
Constructs an IPv4 address from an integer in the range 0 to (2 ^ 32) - 1. For example,
ipv4Address(0)denotes0.0.0.0ipv4Address(4)denotes0.0.0.4ipv4Address(1234)denotes0.0.4.210ipv4Address(123456789)denotes7.91.205.21ipv4Address((2 ^ 32) - 1)denotes255.255.255.255
For numbers outside the range 0..2^32-1, ipv4Address throws an error.
Whereas ipv4Address constructs IP addresses from integers, there is the
ipAddress method to construct IP addresses from strings. Moreover,
we can construct integers from IP addresses using toNumber.
Properties
The ipv4Address function and the
toNumber are inverses: toNumber(ip) == num is true exactly when
ip == ipv4Address(num) is true, for ip an IPv4 address and num an integer in 0..2^32-1. For example:
ipv4Address(toNumber(ipAddress("1.2.3.4"))) == ipAddress("1.2.3.4")toNumber(ipv4Address(1234))) == 1234