Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/pfrazee/listen-random-port

Listen a node HTTP server on a random, unused port
https://github.com/pfrazee/listen-random-port

Last synced: 11 days ago
JSON representation

Listen a node HTTP server on a random, unused port

Awesome Lists containing this project

README

        

# listen-random-port

```js
var listen = require('listen-random-port')

var server = http.createServer(serverFn)
listen(server, function (err, port) {
console.log('Listening', err, port)
// ...
})

// full opts:
listen(server, { from: 5000, to: 6000, host: '127.0.0.1' }, function (err, port) {
console.log('Listening', err, port)
// ...
})
```