Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 32 lines (22 sloc) 0.934 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
NODE-PORTCHECKER
A simple tcp port checker for node

LICENSE MIT
(C) Daniel Zelisko
http://github.com/danielzzz/node-portchecker

DESCRIPTION
This library allows for easy and simple tcp port checking.
It can be used for determining if a given port is open, or to find a first available port

INSTALLATION:
npm install portchecker

API:
getFirstAvailable(startPort, endPort, host, cb)
returns first available port in a given range cb(port, host)

getAllOpen(startPort, endPort, host, cb)
returns array of available ports for a given hosts in a given range cb(openPorts, host)

isOpen(port, host, callback)
returns true if a given host:port is open cb(isOpen, port, host)

setTimeout(milisecs)
configure timeout for port probing (default 400 milisecs)


EXAMPLE:

//find first available port between 80 and 90 on localhost
portchecker.getFirstAvailable(80, 90, 'localhost', function(p, host) { console.log(host+":"+p+" is free");});
Something went wrong with that request. Please try again.