Code Monkey home page Code Monkey logo

tcp-ping's People

Contributors

alexbeletsky avatar apaszke avatar stegano avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tcp-ping's Issues

How to return the data?

Hello,

I have been trying to return the data. It works totally fine when I do console.log....but then I need to use the data for something else.
Please find the code.
Thanks.

pingTest(){ let msg= 'false'; tcpp.probe('www.google.com', 80, function(err, available) { return console.log(available); //msg=available; }); return msg; }

I see msg contains only 'false'.

Ping 'err' argument always undefined

Ping err argument always undefined regardless address valid or not.

Example:

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

// Ping VALID address
tcpp.ping({ address: 'google.com', timeout: 1000, attempts: 1 }, (err, data) => {
    console.log(err); // log `undefined`
});

// Ping INVALID address
tcpp.ping({ address: 'node', timeout: 1000, attempts: 1 }, (err, data) => {
    console.log(err); // log `undefined`
});

No reliable way of telling if the connection was successful or not.

I want to log my WAN availability, so i ping Google and my homepage to test if i can connect to them. Surprisingly probe is always returning true even tough i can not connect to anything at all.

I am not sure if i can just use avg and test for NaN to tell if i have no connection as that is the only clue i get when using ping of whether or not the connection failed. I assume so but i wanted to be sure so i ask here, maybe it would be a good idea to hint at this in the ReadMe.

Timeout not being respected

Shouldn't this return false pretty much immediately? The timeout is 1ms. Instead it's waiting 21 seconds before returning false.

const tcp = require("tcp-ping");

let opts = {
    address: "good address",
    port: bad port,
    timeout: 1
}

tcp.ping({ address: opts.address, port: opts.port, attempts: 1, timeout: opts.timeout }, function(err, data) {
    let available = data.min !== undefined;
    console.log(available);
});

Add support for promises.

I wrapped the ping function inside a promise as below.

const tcpping = opt => new Promise((resolve, reject) => tcpp.ping(opt, (err, data) => err ? reject(err) : resolve(data)));

Perhaps native support for promises could be added.

ping returns undefined time

no matter what i try to do i am getting undefined response time.

    tcp.ping({address:'google.com',attempts:5, timeout:150}, function(err, data){
      console.log(data);
    });

results: [{seq:0, time: undefined, err: {Object},

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.