lib/net/is-port-in-use.js
function isPortInUse(port) {
  _validatePortFormat(port);
  if (isPlatform('unix')) {
    if (isPlatform('linux') && fileExists('/proc/net')) {
      return _isPortInUseRaw(port);
    } else if (isInPath('netstat')) {
      return _isPortInUseNetstat(port);
    } else {
      throw new Error('Cannot check port status');
    }
  } else {
    throw new Error('Port checking not supported on this platform');
  }
}
function isPortInUse(port) {
  _validatePortFormat(port);
  if (isPlatform('unix')) {
    if (isPlatform('linux') && fileExists('/proc/net')) {
      return _isPortInUseRaw(port);
    } else if (isInPath('netstat')) {
      return _isPortInUseNetstat(port);
    } else {
      throw new Error('Cannot check port status');
    }
  } else {
    throw new Error('Port checking not supported on this platform');
  }
}
function isPortInUse ( port ) { _validatePortFormat ( port ) ; if ( isPlatform ( 'unix' ) ) { if ( isPlatform ( 'linux' ) && fileExists ( '/proc/net' ) ) { return _isPortInUseRaw ( port ) ; } else if ( isInPath ( 'netstat' ) ) { return _isPortInUseNetstat ( port ) ; } else { throw new Error ( 'Cannot check port status' ) ; } } else { throw new Error ( 'Port checking not supported on this platform' ) ; } }
Check if the given port is in use
@function $net~isPortInUse
@param {string} port - Port to check
@returns {boolean} - Whether the port is in use or not
@example
// Check if the port 8080 is already in use
$net.isPortInUse(8080);
=> false
Check if the given port is in use