Socket
Socket
Sign inDemoInstall

pick-port

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

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
Weekly downloads
3.8K
increased by19.18%
Maintainers
1
Weekly downloads
 
Created
Source

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

Usage

const freePort = require('free-port');

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

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

freePort({ 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

freePort([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

Package last updated on 30 Jan 2018

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc