Giter Club home page Giter Club logo

tcpie's Introduction

#tcpie NPM version Dependency Status

'ping'-like utility to repeatedly test a remote TCP port for connectivity

tcpie is an simple tool to verify the reliabilty of a network connection to a remote server. It does so by initiating a handshake and immediately terminating the connection afterwards. It was created because similar tools like hping require raw socket access (usually only granted to root), while tcpie runs fine in userspace. Further, an API is provided for use as a module.

##Installation

$ [sudo] npm install -g tcpie

###Example

$ tcpie -c 5 google.com
TCPIE google.com (188.21.9.116) port 80
connected to google.com:80 seq=1 srcport=3238 time=25.8 ms
connected to google.com:80 seq=2 srcport=3239 time=31.9 ms
connected to google.com:80 seq=3 srcport=3240 time=29.1 ms
connected to google.com:80 seq=4 srcport=3241 time=28.9 ms
connected to google.com:80 seq=5 srcport=3242 time=28.5 ms

--- google.com tcpie statistics ---
5 handshakes attempted, 5 succeeded, 0% failed
rtt min/avg/max/stdev = 25.757/28.835/31.908/2.184 ms

##Usage

Usage: tcpie [options] host [port]

Options:

  -h, --help          output usage information
  -V, --version       output the version number
  -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)
  -f, --flood         flood mode, connect as fast as possible
  --color             enable color output

##Module API ###Installation

$ npm install --save tcpie

###Example

var tcpie = require("tcpie");
var pie = tcpie("google.com", 80, {count: 10, interval: 500, timeout: 2000});

pie.on("connect", function(data) {
    console.log("connect", data);
}).on("error", function(data, err) {
    console.log("error", data, err);
}).on("end", function(data) {
    console.log("end", data);
    // -> {
    // ->   sent: 10,
    // ->   success: 10,
    // ->   failed: 0,
    // ->   target: { host: 'google.com', port: 80 }
    // -> }
}).start();

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

Events

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

data argument properties

  • sent number : number of total attempts made.
  • success number : number of successfull attempts.
  • failed number : number of failed attempts.
  • rtt number : roundtrip time in milliseconds. undefined if failed.
  • target object : target details: host and port.
  • socket object : socket details: localAddress, localPort, remoteAddress, remotePort.

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.

© 2015 silverwind, distributed under BSD licence

tcpie's People

Contributors

silverwind avatar

Watchers

Zeke Sikelianos avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.