tcpie
Ping any TCP port
Last updated 5 months ago by silverwind .
BSD-2-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install tcpie 
SYNC missed versions from official npm registry.

tcpie

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.

CLI

Installation

Install Node.js and then do:

$ npm i -g tcpie

Example

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

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

Usage

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

Options:

  -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

Examples:

  $ tcpie google.com
  $ tcpie -i .1 8.8.8.8:53
  $ tcpie -c5 -t.05 aspmx.l.google.com 25
  $ tcpie -i.2 https://google.com

Module API

Installation

$ npm i tcpie

Example

const tcpie = require('tcpie');
const pie = tcpie('google.com', 443, {count: 10, interval: 500, timeout: 2000});

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

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

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

tcpie#start()

Start connecting

tcpie#stop()

Stops connecting

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).

Events

  • 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

Current Tags

  • 9.0.1                                ...           latest (5 months ago)

65 Versions

  • 9.0.1                                ...           5 months ago
  • 9.0.0                                ...           8 months ago
  • 8.0.1                                ...           a year ago
  • 8.0.0                                ...           a year ago
  • 7.0.0                                ...           2 years ago
  • 6.1.0                                ...           2 years ago
  • 6.0.0                                ...           2 years ago
  • 5.0.0                                ...           2 years ago
  • 4.0.2                                ...           2 years ago
  • 4.0.1                                ...           3 years ago
  • 4.0.0                                ...           3 years ago
  • 3.0.11                                ...           3 years ago
  • 3.0.10                                ...           4 years ago
  • 3.0.9                                ...           4 years ago
  • 3.0.8                                ...           4 years ago
  • 3.0.7                                ...           4 years ago
  • 3.0.6                                ...           4 years ago
  • 3.0.5                                ...           5 years ago
  • 3.0.4                                ...           5 years ago
  • 3.0.3                                ...           5 years ago
  • 3.0.2                                ...           5 years ago
  • 3.0.1                                ...           5 years ago
  • 3.0.0                                ...           5 years ago
  • 2.0.1                                ...           5 years ago
  • 2.0.0                                ...           5 years ago
  • 1.2.3                                ...           5 years ago
  • 1.2.2                                ...           5 years ago
  • 1.2.1                                ...           5 years ago
  • 1.2.0                                ...           5 years ago
  • 1.1.2                                ...           5 years ago
  • 1.1.1                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.3                                ...           5 years ago
  • 1.0.2                                ...           6 years ago
  • 1.0.1                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
  • 0.14.1                                ...           6 years ago
  • 0.14.0                                ...           6 years ago
  • 0.13.0                                ...           6 years ago
  • 0.12.5                                ...           6 years ago
  • 0.12.4                                ...           6 years ago
  • 0.12.3                                ...           6 years ago
  • 0.12.2                                ...           6 years ago
  • 0.12.1                                ...           6 years ago
  • 0.12.0                                ...           6 years ago
  • 0.11.0                                ...           6 years ago
  • 0.10.2                                ...           6 years ago
  • 0.10.1                                ...           6 years ago
  • 0.10.0                                ...           6 years ago
  • 0.9.0                                ...           6 years ago
  • 0.8.3                                ...           6 years ago
  • 0.8.2                                ...           6 years ago
  • 0.8.1                                ...           6 years ago
  • 0.8.0                                ...           6 years ago
  • 0.7.0                                ...           6 years ago
  • 0.6.0                                ...           6 years ago
  • 0.5.1                                ...           6 years ago
  • 0.5.0                                ...           6 years ago
  • 0.4.0                                ...           6 years ago
  • 0.3.1                                ...           6 years ago
  • 0.3.0                                ...           6 years ago
  • 0.2.2                                ...           6 years ago
  • 0.2.1                                ...           6 years ago
  • 0.2.0                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 5
This Month 10
Last Day 3
Last Week 2
Last Month 12
Dependencies (5)
Dev Dependencies (5)

Copyright 2014 - 2017 © taobao.org |