Socket
Socket
Sign inDemoInstall

pick-port

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    pick-port

Get a free TCP or UDP port for the given IP address


Version published
Maintainers
1
Install size
7.57 kB
Created

Readme

Source

Get an available TCP or UDP port for the given IP address.

Usage

const pickPort = require('pick-port');

pickPort()
	.then(port =>
	{
		console.log(port);
		//=> 34323
	});

Optionally, provide the TCP/IP protocol family type, IP address and/or port:

pickPort({ type: 'tcp', ip: '10.10.10.1', port: 8000 })
	.then(port =>
	{
		console.log(port);
		//=> 8000 if the given port if free to use, otherwise the corresponding exception is thrown
	});

API

pickPort([options])

Returns a Promise for a port number.

options

Type: Object

type

Type: string

TCP/IP family type. Options for this parameter are 'udp' and 'tcp'. Default value is 'udp'.

port

Type: number

Specific port to be checked. Default value is 0, which means that any free port can be taken.

ip

Type: string

The IP address for which a free port is requested. IPv4 and IPv6 addressing is supported. Default value is '127.0.0.1'.

Keywords

FAQs

Last updated on 31 Jan 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc