class Net::IP

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.cr

Constant Summary

MAX_IPV4_STRING_LEN = "255.255.255.255".size

Class Method Summary

Instance Method Summary

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

def self.parse(s : String) #

[View source]

Instance Method Detail

def ==(other : self) #

[View source]
def default_mask #

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.


[View source]
def interface_local_multicast? #

reports whether ip is an interface-local multicast address.


[View source]
def loopback? #

reports whether ip is a loopback address.


[View source]
def mask(m : IPMask) #

mask returns the result of masking the IP address ip with mask.


[View source]
def multicast? #

reports whether ip is a multicast address.


[View source]
def to16 #

converts the IP address ip to a 16-byte representation. if ip is not an IP address (it is the wrong length), returns nil


[View source]
def to4 #

converts the IPv4 address ip to a 4-byte representation. If ip is not an IPV4 address, returns nil


[View source]
def to_s #

[View source]
def unspecified? #

reports whether ip is an unspecified address, either the IPV4 address 0.0.0.0 or the IPV6 address ::


[View source]