IP::Address::IPv4
Inherits IP::Address < Comparable < Comparable < Struct < Value < Object
Constants
ADDRESS_MAX = 4294967295_u32
ADDRESS_WIDTH = 32_u8
Constructors
new(string : String) : self
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.
new(sockaddr : Pointer(LibC::SockaddrIn)) : self
Constructs a new IP::Address::IPv4 from a SockaddrIn*.
Class methods
new?(string : String) : self | Nil
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 methods
[](index : Int) : UInt8
Returns the requested octet from the address.
Raises OutOfBoundsError if the requested octet is not [0..3].
to_sockaddr(port : UInt16 = 0_u16) : Pointer(LibC::Sockaddr)
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.