Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added checkPortStatuses method #5

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
123 changes: 65 additions & 58 deletions README.md
@@ -1,58 +1,65 @@


## The What ## The What


The portscanner module is an asynchronous JavaScript port scanner for Node.js. The portscanner module is an asynchronous JavaScript port scanner for Node.js.


Portscanner can check a port, or range of ports, for 'open' or 'closed' Portscanner can check a port, or range of ports, for 'open' or 'closed'
statuses. statuses.


## The How ## The How


### To Install ### To Install


```bash ```bash
npm install portscanner npm install portscanner
``` ```


### To Use ### To Use


A brief example: A brief example:


```javascript ```javascript
var portscanner = require('portscanner') var portscanner = require('portscanner')


// Checks the status of a single port // Checks the status of a single port
portscanner.checkPortStatus(3000, 'localhost', function(error, status) { portscanner.checkPortStatus(3000, 'localhost', function(error, status) {
// Status is 'open' if currently in use or 'closed' if available // Status is 'open' if currently in use or 'closed' if available
console.log(status) console.log(status)
}) })


// Find the first available port. Asynchronously checks, so first port // Checks the status of a all ports in a range
// determined as available is returned. portscanner.checkPortStatuses(3000, 4000, 'localhost', function(error, statuses) {
portscanner.findAPortNotInUse(3000, 3010, 'localhost', function(error, port) { // Statuses is an array of status objects,
console.log('AVAILABLE PORT AT: ' + port) // in the format of {port: port, status: status}
}) console.log(statuses)

})
// Find the first port in use or blocked. Asynchronously checks, so first port
// to respond is returned. // Find the first available port. Asynchronously checks, so first port
portscanner.findAPortInUse(3000, 3010, 'localhost', function(error, port) { // determined as available is returned.
console.log('PORT IN USE AT: ' + port) portscanner.findAPortNotInUse(3000, 3010, 'localhost', function(error, port) {
}) console.log('AVAILABLE PORT AT: ' + port)
``` })


The example directory contains a more detailed example. // Find the first port in use or blocked. Asynchronously checks, so first port

// to respond is returned.
### To Test portscanner.findAPortInUse(3000, 3010, 'localhost', function(error, port) {

console.log('PORT IN USE AT: ' + port)
Bleh. I am a fan of testing, but currently looking into an easier way to test })
several HTTP connections. If any ideas, please message me. ```


## The Future The example directory contains a more detailed example.


Please create issues, or better yet, pull requests, for port scanning related ### To Test
features you'd like to see included.

Bleh. I am a fan of testing, but currently looking into an easier way to test
## The License (MIT) several HTTP connections. If any ideas, please message me.


Released under the MIT license. See the LICENSE file for the complete wording. ## The Future


Please create issues, or better yet, pull requests, for port scanning related
features you'd like to see included.

## The License (MIT)

Released under the MIT license. See the LICENSE file for the complete wording.