TCP Ping is a Node.JS based TCP ping utility written in Typescript.
``sh`
yarn add nodejs-tcp-ping
`sh`
npm install nodejs-tcp-ping --save
`javascript
const nodejsTcpPing = require('nodejsTcpPing');
// If you are not specify any options
// then ping localhost:80 five times
// with 5000ms timeout
nodejsTcpPing.tcpPing().then(results => {
// It return an array of ping data
// The returned data array (result) is looks like this,
// if everthing was successful: [{ ping: number }, ...]
// if some attempts timedout: [ { ping: null, error: 'Connection timed out' } ]
}).catch(reason => {
// Or a reason why it failed
});
// There is the full specification of options
nodejsTcpPing.tcpPing({
attempts: 5,
host: 'localhost',
port: 80,
timeout: 5000
}).then(results => {
// It return an array of ping data
}).catch(reason => {
// Or a reason why it failed
});
`
`typescript
import { tcpPing, IPingData } from 'nodejsTcpPing';
tcpPing().then((result: IPingData[]) => {
// ...
}).catch((reason: any) => {
// ...
});
// Or
tcpPing({
attempts: 5,
host: 'localhost',
port: 80,
timeout: 5000
}).then((result: IPingData[]) => {
// ...
}).catch((reason: any) => {
// ...
});
`
`sh`
yarn
`sh`
yarn build
`sh`
yarn test
`sh`
npm install
`sh`
npm run build
`sh``
npm test