class Net::IP
- Net::IP
- Net::IPBase
- Reference
- Object
Overview
An IP is a single IP address, a slice of bytes. Functions in this package accept either 4-byte (IPv4) or 16-byte (IPv6) slices as input.
Note that in this documentation, referring to an IP address as an IPv4 address or an IPv6 address is a semantic property of the address, not just the length of the byte slice: a 16-byte slice can still be an IPv4 address.
Defined in:
net/ip.crConstant Summary
-
MAX_IPV4_STRING_LEN =
"255.255.255.255".size
Class Method Summary
Instance Method Summary
- #==(other : self)
-
#default_mask
default_mask returns the default IP mask for the IP address ip.
-
#interface_local_multicast?
reports whether ip is an interface-local multicast address.
-
#loopback?
reports whether ip is a loopback address.
-
#mask(m : IPMask)
mask returns the result of masking the IP address ip with mask.
-
#multicast?
reports whether ip is a multicast address.
-
#to16
converts the IP address ip to a 16-byte representation.
-
#to4
converts the IPv4 address ip to a 4-byte representation.
- #to_s
-
#unspecified?
reports whether ip is an unspecified address, either the IPV4 address 0.0.0.0 or the IPV6 address ::
Instance methods inherited from class Net::IPBase
==(other : self)
==,
hash(hasher)
hash
Constructor methods inherited from class Net::IPBase
new(ptr : Pointer(UInt8), size : Int)new(size : Int)
new(size : Int, &block) new
Class methods inherited from class Net::IPBase
empty
empty
Class Method Detail
Instance Method Detail
default_mask returns the default IP mask for the IP address ip. Only IPv4 addresses have default masks; default_mask returns nil if ip is not a valid IPv4 address.
mask returns the result of masking the IP address ip with mask.
converts the IP address ip to a 16-byte representation. if ip is not an IP address (it is the wrong length), returns nil
converts the IPv4 address ip to a 4-byte representation. If ip is not an IPV4 address, returns nil
reports whether ip is an unspecified address, either the IPV4 address 0.0.0.0 or the IPV6 address ::