TCP Ping Utility

0.1.1 · abandoned · verified Sun Apr 19

This Node.js utility provides TCP-based ping functionality, enabling users to test the availability and measure the latency of specific services on given addresses and ports. Unlike traditional ICMP `ping` tools, `tcp-ping` avoids issues with ICMP-blocked servers and offers faster results by immediately dropping connections after acceptance. It's particularly useful for verifying service-level availability rather than just general network connectivity. The package's current and only documented version is 0.1.1, indicating a very early stage of development or a project that is no longer actively maintained. Its release cadence is effectively non-existent. Key differentiators include its speed, the ability to target specific ports and services, and its resilience to ICMP filtering, making it more effective for certain server monitoring scenarios.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to use `tcp-ping` to both probe for service availability and measure latency statistics for a given address and port.

const tcpp = require('tcp-ping');

const targetAddress = '46.28.246.123'; // Replace with a real IP or hostname
const targetPort = 80;

tcpp.probe(targetAddress, targetPort, function(err, available) {
    if (err) {
        console.error(`Probe error for ${targetAddress}:${targetPort}:`, err.message);
    } else {
        console.log(`Service at ${targetAddress}:${targetPort} available: ${available}`);
    }
});

tcpp.ping({ address: targetAddress, port: targetPort, attempts: 5, timeout: 2000 }, function(err, data) {
    if (err) {
        console.error(`Ping error for ${targetAddress}:${targetPort}:`, err.message);
    } else {
        console.log(`Ping results for ${targetAddress}:${targetPort}:`);
        console.log(`  Attempts: ${data.attempts}`);
        console.log(`  Average latency: ${data.avg.toFixed(2)}ms`);
        console.log(`  Min latency: ${data.min.toFixed(2)}ms`);
        console.log(`  Max latency: ${data.max.toFixed(2)}ms`);
        // console.log('  Raw results:', data.results);
    }
});

view raw JSON →