waitforsocket
wait for a socket to open
Last updated 6 years ago by refractalize .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install waitforsocket 
SYNC missed versions from official npm registry.

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.

Current Tags

  • 0.1.1                                ...           latest (6 years ago)

2 Versions

  • 0.1.1                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 4
Dependencies (1)
Dev Dependencies (3)

Copyright 2014 - 2016 © taobao.org |