net-address
    Preparing search index...

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

    const socketAddr = new SocketAddrV4({port: 6372}); // new SocketAddrV4({addr: Ipv4Addr.UNSPECIFIED, port: 6372});
    tcpServer.listen(socketAddr.asNodeListenerOptions(), () => {});
    udpSocket.bind(socketAddr, () => {});
    tcpServer.listen({...socketAddr.asNodeListenerOptions(), ipv6Only: true}, () => {});

    v0.0.1

    Index

    Constructors

    • Creates a new SocketAddrV4 instance.

      Parameters

      • options: { addr?: Ipv4Addr; port: number }

        The options for creating the socket address.

        • Optionaladdr?: Ipv4Addr

          The IPv4 address. Defaults to Ipv4Addr.UNSPECIFIED.

        • port: number

          The port number.

      Returns SocketAddrV4

    Properties

    address: string
    family: "ipv4" = 'ipv4'
    port: number

    Methods

    • 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

    • Gets the raw Ipv4Addr instance representing the IP address of this socket address.

      Returns Ipv4Addr

      Ipv4Addr instance of the socket address's IP address.

      v0.0.1

    • Returns a string representation of this socket address.

      Returns string

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

      v0.0.1