dooaki/net-empty_port

find a free TCP/UDP port

Installs: 14

Dependents: 1

Stars: 1

Watchers: 1

Language: PHP

0.0.2 2013-10-02 06:50 UTC

README

Build Status Coverage Status

Net-EmptyPort is php library finding an empty TCP/UDP port.

Original is cpan module Net::EmptyPort

Requirements

  • PHP 5.3 or later
  • Sockets Support enabled (--enable-sockets)

Installation

you can install the script with Composer.

in your composer.json file:

{
    "require": {
        "dooaki/net-empty_port": "dev-master"
    }
}
composer.phar install

Methods

find([$port, $proto])

find free TCP port

  use dooaki\Net\EmptyPort;

  $port = EmptyPort::find(5963); // 5963..65535

find free UDP port

  $port = EmptyPort::find(null, 'udp'); // 1024..65535

isPortUsed($port, [$proto])

checks the given port is already used. also works for UDP

  $dns_udp_used = EmptyPort::isPortUsed(53, 'udp');

wait($port, $max_wait_sec[, $protol])

wait for a particular port is available for connect.

Author

do_aki

License

MIT License