net-address
    Preparing search index...

    Class Ipv4Addr

    Represents an IPv4 address.

    const addr1 = Ipv4Addr.from('192.168.0.1').unwrap();
    const addr2 = new Ipv4Addr(192, 168, 0, 1);
    const addr3 = new Ipv4Addr(0xc0a80001);

    v0.0.1

    Index

    Constructors

    • Creates a new IPv4 address from four octets.

      Parameters

      • num1: number

        The first octet.

      • num2: number

        The second octet.

      • num3: number

        The third octet.

      • num4: number

        The fourth octet.

      Returns Ipv4Addr

      new Ipv4Addr(192, 168, 0, 1) // creates the address `192.168.0.1`
      
    • Creates a new IPv4 address from an integer value.

      Parameters

      • integerValue: number

        The integer representation of the IPv4 address.

      Returns Ipv4Addr

      new Ipv4Addr(0xc0a80001) // creates the address `192.168.0.1` from the integer value `0xc0a80001`
      

    Properties

    family: "ipv4" = 'ipv4'

    The address family identifier for IPv4 addresses.

    v0.0.1

    BITS: 32

    The number of bits in an IPv4 address.

    v0.0.1

    BROADCAST: Ipv4Addr = ...

    The broadcast address 255.255.255.255.

    v0.0.1

    LOCALHOST: Ipv4Addr = ...

    The localhost address 127.0.0.1.

    v0.0.1

    UNSPECIFIED: Ipv4Addr = ...

    The unspecified address 0.0.0.0.

    v0.0.1

    Methods

    • Checks whether this address is the unspecified address.

      Returns boolean

      true when the address is 0.0.0.0, otherwise false.

      v0.0.1

    • Encodes this address to a 4-byte buffer.

      Parameters

      • OptionallittleEndian: boolean

      Returns ArrayBuffer

      An ArrayBuffer containing the IPv4 integer value.

      v0.0.1

    • Converts this address to an IPv4-compatible IPv6 address.

      Returns Ipv6Addr

      An IPv6 address in the form ::a.b.c.d.

      v0.0.1

    • Converts this address to an IPv4-mapped IPv6 address.

      Returns Ipv6Addr

      An IPv6 address in the form ::ffff:a.b.c.d.

      v0.0.1

    • Formats this address as dotted-decimal text.

      Returns string

      The IPv4 string representation, such as 192.168.0.1.

      v0.0.1