struct IP::Address::IPv4
- IP::Address::IPv4
- IP::Address
- Struct
- Value
- Object
Defined in:
ip/address/ipv4.crConstant Summary
-
ADDRESS_MAX =
4294967295_u32 -
ADDRESS_WIDTH =
32_u8
Constructors
-
.new(value : Value)
Creates a new
IP::Address::IPv4from a{{ Value.id }}value. -
.new(string : String) : self
Constructs a new
IP::Address::IPv4from the contents of aString. -
.new(octets : Octets) : self
Constructs a new
IP::Address::IPv4from aTupleof 4UInt8. -
.new(sockaddr : ::Pointer(LibC::SockaddrIn)) : self
Constructs a new
IP::Address::IPv4from aSockaddrIn*. -
.new(value : Int) : self
Constructs a new
IP::Address::IPv4from anInt. -
.new?(string : String) : self?
Constructs a new
IP::Address::IPv4from the contents of aString.
Instance Method Summary
-
#[](index : Int) : UInt8
Returns the requested octet from the address.
-
#loopback? : Bool
Informs if the address is in the loopback address space or not.
-
#max_value : Value
The maximum address of this type.
-
#octets : Octets
Returns a
Tupleof 4UInt8which represent the addresses octets. -
#to_s(io : IO)
Appends the presentation representation of the address to the given
IO. -
#to_sockaddr(port : UInt16 = 0_u16) : ::Pointer(LibC::Sockaddr)
Produces the c
sockaddr_instruct required bybind,connect,sendto, andsendmsg. -
#value : Value
The internally stored value of the address.
-
#value_network : LibC::UInt32T
The internally stored value of the address in network byte order.
-
#width : UInt8
The width of the address type.
Instance methods inherited from struct IP::Address
+(other : Int) : self
+,
-(other : Int) : self
-,
<=>(other : IP::Address) : Int<=>(other : IP::Block) : Int <=>, [](index : Int) [], adjacent?(other : IP::Block)
adjacent?(other : IP::Address) adjacent?, family : Socket::Family family, hash(hasher) hash, inspect(io : IO) : Nil inspect, ipv4? : Bool ipv4?, ipv6? : Bool ipv6?, loopback? : Bool loopback?, max_value max_value, to_sockaddr to_sockaddr, value value, value_network value_network, width width
Constructor methods inherited from struct IP::Address
[](string : String) : self
[],
[]?(string : String) : self?
[]?,
new(string : String) : selfnew(sockaddr : ::Pointer(LibC::Sockaddr)) : self new, new?(string : String) : self? new?
Class methods inherited from struct IP::Address
ipv4(string : String)
ipv4,
ipv4?(string : String)
ipv4?,
ipv6(string : String)
ipv6,
ipv6?(string : String)
ipv6?
Constructor Detail
Creates a new IP::Address::IPv4 from a {{ Value.id }} value.
Constructs a new IP::Address::IPv4 from the contents of a String. Expects an address
in the form of [0-255].[0-255].[0-255].[0-255].
Raises: MalformedError when the input is malformed.
Constructs a new IP::Address::IPv4 from a Tuple of 4 UInt8.
Constructs a new IP::Address::IPv4 from a SockaddrIn*.
Constructs a new IP::Address::IPv4 from the contents of a String. Expects an address
in the form of [0-255].[0-255].[0-255].[0-255].
Returns nil when the input is malformed.
Instance Method Detail
Returns the requested octet from the address.
Raises OutOfBoundsError if the requested octet is not [0..3].
Returns a Tuple of 4 UInt8 which represent the addresses octets.
Produces the c sockaddr_in struct required by bind, connect, sendto, and sendmsg.
Note: Unix Network Programming: Volume 1, 3rd Edition, p.68
- sin_len: default size of this struct is 16 bytes. Is set internally when passed though
bind,connect,sendto, orsendmsg. - sin_zero: is unused.
The internally stored value of the address in network byte order.