# tcp-ping

> A ping utility using TCP connection

Latest version **0.1.1** (published 2014-09-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install tcp-ping
pnpm add tcp-ping
yarn add tcp-ping
bun add tcp-ping
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2014-09-03 |
| First published | 2014-04-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/tcp-ping) |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 126 |
| Author | Adam Paszke |
| Maintainers | wesolyromek |
| Keywords | ping, util, tcp, availability |

## Links

- npm: https://www.npmjs.com/package/tcp-ping
- Repository: https://github.com/wesolyromek/tcp-ping
- Issues: https://github.com/wesolyromek/tcp-ping/issues
- npm.io page: https://npm.io/package/tcp-ping

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2014-09-03
- 0.1.0 — 2014-04-29
- 0.0.1 — 2014-04-26

## README

tcp-ping
========

TCP ping utility for node.js. You can test if chosen address accepts connections at desired port and find out your latency. Great for service availability testing.

#####Why not ```ping``` wrapper?

* It's much faster than ```ping``` tool (as soon as connection gets accepted, it's dropped and a new measure is conducted immediately), so there's no unnecessary waiting between requests.
* It allows you to test a specific service, not the whole connection
* Some servers drop ICMP echo without any response, even when online. TCP can work in such cases.

###Install

```
npm install tcp-ping
```

###Functions

#####ping(options, callback)

```options``` is an object, which may contain several properties:

* address (address to ping; defaults to ```localhost```)
* port (defaults to ```80```)
* timeout (in ms; defaults to 5s)
* attempts (how many times to measure time; defaults to 10)

```callback``` should be a function with arguments in node convention - ```function(err, data)```.

Returned data is an object which looks like this:
```javascript
{
  address: '46.28.246.123',
  port: 80,
  attempts: 10,
  avg: 19.7848844,
  max: 35.306233,
  min: 16.526067,
  results:
   [
    { seq: 0, time: 35.306233 },
    { seq: 1, time: 16.585919 },
    ...
    { seq: 9, time: 17.625968 }
   ]
}
```

#####probe(address, port, callback)
```callback``` is a node style callback ```function(err, data)```, where data is true if the server is available and false otherwise.

###Usage

```javascript
var tcpp = require('tcp-ping');

tcpp.probe('46.28.246.123', 80, function(err, available) {
    console.log(available);
});

tcpp.ping({ address: '46.28.246.123' }, function(err, data) {
    console.log(data);
});
```

---
_Source: https://npm.io/package/tcp-ping · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
