class InetAddress
Represents an v4 or v6 Internet Protocol (IP) address.
Members
Array
buffer
Immutable buffer that represents the IP address
Number
length
Returns the length of the underlying buffer
Number
version
Returns the Ip version (4 or 6)
Constructor
InetAddress
(Buffer
buffer)
Creates a new instance of InetAddress
Methods
equals
(InetAddress
other)
Compares 2 addresses and returns true if the underlying bytes are the same
InetAddress.fromString
(String
value)
Parses the string representation and returns an Ip address
- Static
- This function is static
getBuffer
()Returns the underlying buffer
inspect
()Provide the name of the constructor and the string representation
toJSON
()Returns the string representation. Method used by the native JSON.stringify() to serialize this instance.
toString
([String
encoding])
Returns the string representation of the IP address.
For v4 IP addresses, a string in the form of d.d.d.d is returned.
For v6 IP addresses, a string in the form of x:x:x:x:x:x:x:x is returned, where the ‘x’s are the hexadecimal values of the eight 16-bit pieces of the address, according to rfc5952. In cases where there is more than one field of only zeros, it can be shortened. For example, 2001:0db8:0:0:0:1:0:1 will be expressed as 2001:0db8::1:0:1.