CLI tool to ping any TCP port


> Ping any TCP port

tcpie is a tool to measure latency and verify the reliabilty of a TCP connection. It does so by initiating a handshake followed by an immediately termination of the socket. While many existing tools require raw socket access, tcpie runs fine in user space. An API for use as a module is also provided.



Install Node.js and then do:

$ sudo npm install -g tcpie


$ tcpie -c 5 443
TCPIE ( port 443
connected to seq=1 srcport=59053 time=12.9 ms
connected to seq=2 srcport=59054 time=10.0 ms
connected to seq=3 srcport=59055 time=10.1 ms
connected to seq=4 srcport=59056 time=11.4 ms
connected to seq=5 srcport=59057 time=10.4 ms

--- tcpie statistics ---
5 handshakes attempted, 5 succeeded, 0% failed
rtt min/avg/max/stdev = 10.012/10.970/12.854/1.190 ms


Usage: tcpie [options] host[:port]|url [port|80]


  -v, --version       output version
  -c, --count <n>     number of connects (default: infinite)
  -i, --interval <n>  wait n seconds between connects (default: 1)
  -t, --timeout <n>   connection timeout in seconds (default: 3)
  -T, --timestamp     add timestamps to output
  -f, --flood         flood mode, connect as fast as possible
  -C, --no-color      disable color output


  $ tcpie
  $ tcpie -i .1
  $ tcpie -c5 -t.05 25
  $ tcpie -i.2

Module API


$ npm install --save tcpie


var tcpie = require('tcpie');
var pie = tcpie('', 80, {count: 10, interval: 500, timeout: 2000});

pie.on('connect', function(stats) {'connect', stats);
}).on('error', function(err, stats) {
  console.error(err, stats);
}).on('timeout', function(stats) {'timeout', stats);
}).on('end', function(stats) {;
  // -> {
  // ->   sent: 10,
  // ->   success: 10,
  // ->   failed: 0,
  // ->   target: { host: '', port: 80 }
  // -> }

tcpie(host, [port], [options])

  • host string : the destination host name or IP address. Required.
  • port number : the destination port. Default: 80.
  • opts object : options for count, interval and timeout. Defaults: Infinity, 1000, 3000.

options object

  • count number : the number of connection attempts in milliseconds (default: Infinity).
  • interval number : the interval between connection attempts in milliseconds (default: 1000).
  • timeout number : the connection timeout in milliseconds (default: 3000).


  • connect : Arguments: stats. Connection attempt succeeded.
  • timeout : Arguments: stats. Connection attempt ran into the timeout.
  • error : Arguments: err, stats. Connection attempt failed.
  • end : Arguments: stats. All connection attempts have finished.

stats argument properties

  • sent number : number of total attempts made.
  • success number : number of successfull attempts.
  • failed number : number of failed attempts.
  • target object : target details: host and port.

The following properties are present on all events except end: - rtt number : roundtrip time in milliseconds. undefined if failed. - socket object : socket details: localAddress, localPort, remoteAddress, remotePort.

© silverwind, distributed under BSD licence

Related Repositories



CLI tool to ping any TCP port ...