https://github.com/danielstjules/openports
Find multiple open ports in node
https://github.com/danielstjules/openports
nodejs open ports
Last synced: 5 months ago
JSON representation
Find multiple open ports in node
- Host: GitHub
- URL: https://github.com/danielstjules/openports
- Owner: danielstjules
- License: mit
- Created: 2015-08-15T19:07:36.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-08-16T19:47:08.000Z (about 10 years ago)
- Last Synced: 2025-04-20T21:04:43.443Z (6 months ago)
- Topics: nodejs, open, ports
- Language: JavaScript
- Homepage:
- Size: 129 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# openports
Find multiple open ports.
[](https://travis-ci.org/danielstjules/openports)
## Installation
`npm install --save openports`
## Usage
``` javascript
/**
* Returns n open ports. Uses port 0 for port discovery, and binds to all ports
* prior to releasing them to help avoid race conditions. Accepts an optional
* callback, otherwise it returns a promise.
*
* @param {int} n Number of ports to open
* @param {function} [fn] Optional callback to invoke
* @returns {Promise} An array of port numbers
*/
```## Example
``` javascript
var openports = require('openports');openports(1, function(err, ports) {
console.log(ports); // [12345]
});openports(2).then(function(ports) {
console.log(ports); // [12345, 12346]
});
```