https://github.com/featurist/waitforsocket
wait for a socket to open
https://github.com/featurist/waitforsocket
Last synced: 10 months ago
JSON representation
wait for a socket to open
- Host: GitHub
- URL: https://github.com/featurist/waitforsocket
- Owner: featurist
- Created: 2014-07-09T15:44:09.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-07-09T15:51:24.000Z (over 11 years ago)
- Last Synced: 2025-02-20T05:46:15.509Z (11 months ago)
- Language: PogoScript
- Size: 125 KB
- Stars: 1
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Wait for a Socket to Open
var waitForSocket = require('waitforsocket');
waitForSocket('localhost', 4567, {timeout: 2000}).then(function () {
console.log("socket open");
// do stuff with socket, connect via HTTP, Redis, etc.
}, function (error) {
console.log("socket did not open: ", error);
});
## API
waitForSocket(host, port, [options]) => promise
* `host` hostname, i.e. `localhost` or `example.com`
* `port` the port, i.e. `80`, or `6379`
* `options` an object containing the following properties
* `timeout` the timeout in milliseconds, default: 1000 (1 sec)
returns a promise.