• Check the Connection (Time) to a Host + Port

    Parameters

    • host: string | IPAddress<4 | 6>
    • port: number
    • timeout: number = 10000

    Returns Promise<number | false>

    ms it took to connect or false if failed

    Example

    import { network } from "@rjweb/utils"

    // host, port, timeout ms
    await network.test('127.0.0.1', 80, 5000) // 7.270833998918533

    Since

    1.1.0

    Supports

    nodejs

    Default

    timeout = 10000