Skip to content

Instantly share code, notes, and snippets.

View darrachequesne's full-sized avatar

Damien Arrachequesne darrachequesne

  • Lille, France
View GitHub Profile
@mikeal
mikeal / gist:1840641
Created February 16, 2012 01:33
get a new/clean port with node.js
var portrange = 45032
function getPort (cb) {
var port = portrange
portrange += 1
var server = net.createServer()
server.listen(port, function (err) {
server.once('close', function () {
cb(port)