https://github.com/ppeeou/ping-tcp-js
ping
https://github.com/ppeeou/ping-tcp-js
Last synced: 10 months ago
JSON representation
ping
- Host: GitHub
- URL: https://github.com/ppeeou/ping-tcp-js
- Owner: ppeeou
- License: mit
- Created: 2019-01-10T15:40:12.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-03-17T00:12:30.000Z (over 2 years ago)
- Last Synced: 2025-08-21T11:44:50.355Z (10 months ago)
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/ping-tcp-js
- Size: 219 KB
- Stars: 10
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Welcome to 👋
# install
```
npm install ping-tcp-js
```
# ping
- param
```ts
const client = require("ping-tcp-js");
// or
import client from "ping-tcp-js";
const host = "google.com";
const port = 80;
await client.ping(
{ host, port },
{ timeout: 5000 } // optional
);
```
1. host
```ts
const client = require("ping-tcp-js");
// or
import client from "ping-tcp-js";
const host = "google.com";
const port = 80;
client
.ping({ host, port })
.then(() => console.log("connect ping"))
.catch((e) => console.error("not disconnet", e));
```
2. url
```ts
const client = require("ping-tcp-js");
// or
import client from "ping-tcp-js";
const host = "https://google.com";
client
.ping({ host })
.then(() => console.log("connect ping"))
.catch((e) => console.error("not disconnet", e));
```
# pingBackOff
time : Reconnect time
count : Number of times
- param
```ts
const client = require("ping-tcp-js");
// or
import client from "ping-tcp-js";
const host = "google.com";
const port = 80;
// or
client.pingBackOff({ host, port }, { time: 5000, count: 10, timeout: 5000 });
```
1. host
```ts
const host = "google.com";
const port = 80;
client
.pingBackOff({ host, port }, { time: 5000, count: 10, timeout: 5000 })
.then(() => console.log("connect pingBackOff"))
.catch((e) => console.error("not disconnet", e));
```
2. url
```ts
const host = "https://google.com";
client
.pingBackOff({ host: host }, { time: 5000, count: 10, timeout: 5000 })
.then(() => console.log("connect pingBackOff"))
.catch((e) => console.error("not disconnet", e));
```
## Test
```ts
npm run test
```