portscanner-sync
The portscanner module is a synchronous port scanner for Node.js
Portscanner can check a port, or range of ports, for 'open' or 'closed' statuses.
Install
npm install portscanner-sync
Usage
A brief example:
const portScanner = ;const to = to; let main = async { let err care = ; let status; let port; // Checks the status of an individual port. err care = await ; status = care; if err console else console err care = await ; status = care; if err console else console err care = await ; status = care; if err console else console err care = await ; status = care; if err console else console // Finds a port that a service is listening on err care = await ; port = care if err console else console err care = await ; port = care if err console else console }
The example directory contains a more detailed example.
Test
npm test
API
Refer to the documentation
Modules
Functions
- checkPortStatus(port, [host], timeout) ⇒
Array.<string>
- findAPortInUse(postList, [host]) ⇒
Array.<string>
- findAPortNotInUse()
Finds the first port with a status of 'closed', implying the port is not in use. Accepts identical parameters as findAPortInUse
- findAPortWithStatus(...params)
portscanner
Array.<string>
checkPortStatus(port, [host], timeout) ⇒ Kind: global function
Returns: Array.<string>
- - [err, success]. success is either of closed/open. Closed if port is not in use, open otherwise
Param | Type | Default | Description |
---|---|---|---|
port | Number |
Port to check status on. | |
[host] | String |
'127.0.0.1' |
Host of where to scan. |
timeout | Number |
400 |
timeout. |
Array.<string>
findAPortInUse(postList, [host]) ⇒ Kind: global function
Returns: Array.<string>
- - [error, port]
Param | Type | Default | Description |
---|---|---|---|
postList | Array |
Array of ports to check status on. | |
[host] | String |
'127.0.0.1' |
Host of where to scan. |
Example
// scans 3000 and 3002 only, not 3001.portscanner
findAPortNotInUse()
Finds the first port with a status of 'closed', implying the port is not in use. Accepts identical parameters as findAPortInUse
findAPortWithStatus(...params)
Kind: global function
Param | Type | Description |
---|---|---|
...params | params |
Params as passed exactly to findAPortInUse and findAPortNotInUse. |
CSECO
Developed byCSECO is a mechatronics firm specializing in engineering technology to be cheap enough to be affordable to low income earners.