waitforsocket
v0.1.1
Published
wait for a socket to open
Downloads
205
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]) => promisehosthostname, i.e.localhostorexample.comportthe port, i.e.80, or6379optionsan object containing the following propertiestimeoutthe timeout in milliseconds, default: 1000 (1 sec)
returns a promise.
