net-address
    Preparing search index...

    Class SocketAddrV4

    Represents an IPv4 socket address, consisting of an IPv4 address and a port number.

    const socketAddr = new SocketAddrV4({port: 6372}); // 0.0.0.0:6372
    tcpServer.listen(socketAddr.asNodeListener(), () => {});
    udpSocket.bind(socketAddr.asNodeBind(), () => {});
    tcpServer.listen({...socketAddr.asNodeListener(), ipv6Only: true}, () => {});

    v0.0.1

    Index
    • Creates a new SocketAddrV4 instance.

      Parameters

      • options: number | { address?: Ipv4Addr; port: number }

        The options for creating the socket address or a port number.

        • number
        • { address?: Ipv4Addr; port: number }
          • Optionaladdress?: Ipv4Addr

            The IPv4 address. Defaults to Ipv4Addr.UNSPECIFIED.

          • port: number

            The port number.

      Returns SocketAddrV4

    address: Ipv4Addr

    IPv4 address of the socket address.

    v0.0.1

    family: "ipv4" = 'ipv4'

    Address family of the socket address.

    v0.0.1

    port: number

    Port number of the socket address.

    v0.0.1

    • Returns an object suitable for use as options in Node.js dgram.Socket.bind() method.

      Returns { address: string; port: number }

      An object containing the port and address properties.

      v0.1.0

    • Returns an object suitable for use as options in Node.js net.Server.listen() method.

      Returns { host: string; port: number }

      An object containing the port and host properties.

      v0.0.1

    • Compares this socket address with another for equality.

      Parameters

      • Optionalother: unknown

        The other socket address to compare with.

      Returns boolean

      true if the socket addresses are equal, false otherwise.

      v0.2.0

    • Returns a string representation of this socket address.

      Returns string

      The string representation in the format "address:port".

      v0.0.1

    • Creates a new SocketAddrV4 instance from a string representation or throws an error if the input is invalid.

      Parameters

      • value: string

        The string representation of the socket address in the format "address:port".

      Returns SocketAddrV4

      The SocketAddrV4 instance.

      v0.2.0