Net_Portscan::checkPortRange() – check for available services


require_once 'Net/Portscan.php';

array Net_Portscan::checkPortRange ( string $host , integer $minPort , integer $maxPort , integer $timeout = 30 )


This function checks if there are services available at the specified ports on the specified machine.


  • string $host - address of the host to check

  • string $minPort - lowest port to test to check

  • string $maxPort - highest port to test to check

  • string $timeout - time in seconds to wait for every response from host

    If you run into timeout problems despite setting this parameter to a reasonably high value, you need to make sure that the configuration directive default_socket_timeout in the php.ini configuration file does not force the maximum timeout down to a lower value.

Return value

array - An associative array containing the scanning results for each port.


This function can be called statically.


Using checkPortRange

require_once "Net_Portscan/Portscan.php";

"Scanning localhost ports 70-90\n";
$result Net_Portscan::checkPortRange("localhost"7090);

foreach (
$result as $port => $element) {
    if (
"A service has been found on port " $port ".\n";
    } else {
"No service has been found on port " $port ".\n";
check for available service (Previous) port number of a service (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.