Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tcp-port-used

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tcp-port-used

A simple Node.js module to check if a TCP port is already bound.

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
724K
decreased by-39.94%
Maintainers
1
Weekly downloads
 
Created

What is tcp-port-used?

The tcp-port-used npm package is a utility for checking the status of TCP ports. It allows you to determine if a specific port is in use, wait for a port to become available, or wait for a port to be used. This can be particularly useful for network-related tasks, such as ensuring that a server has started or stopped correctly.

What are tcp-port-used's main functionalities?

Check if a port is in use

This feature allows you to check if a specific TCP port is currently in use. The code sample demonstrates how to check if port 8080 is in use and logs the result.

const tcpPortUsed = require('tcp-port-used');

const port = 8080;
tcpPortUsed.check(port)
  .then(inUse => {
    console.log(`Port ${port} is ${inUse ? 'in use' : 'free'}`);
  })
  .catch(err => {
    console.error('Error on check:', err.message);
  });

Wait for a port to become available

This feature allows you to wait until a specific TCP port becomes available. The code sample demonstrates how to wait until port 8080 is free, checking every 500ms for up to 30 seconds.

const tcpPortUsed = require('tcp-port-used');

const port = 8080;
tcpPortUsed.waitUntilFree(port, 500, 30000)
  .then(() => {
    console.log(`Port ${port} is now free`);
  })
  .catch(err => {
    console.error('Error on waitUntilFree:', err.message);
  });

Wait for a port to be used

This feature allows you to wait until a specific TCP port is in use. The code sample demonstrates how to wait until port 8080 is in use, checking every 500ms for up to 30 seconds.

const tcpPortUsed = require('tcp-port-used');

const port = 8080;
tcpPortUsed.waitUntilUsed(port, 500, 30000)
  .then(() => {
    console.log(`Port ${port} is now in use`);
  })
  .catch(err => {
    console.error('Error on waitUntilUsed:', err.message);
  });

Other packages similar to tcp-port-used

Keywords

FAQs

Package last updated on 18 Dec 2013

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