Net_Portscan::checkPort() – check for available service


require_once 'Net/Portscan.php';

boolean Net_Portscan::checkPort ( string $host , integer $port , integer $timeout = 30 )


This function checks if there is a service available at the specified port on the specified machine.


  • string $host - address of the host to check

  • string $port - port to check

  • string $timeout - time in seconds to wait for 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

boolean - Returns TRUE on success, FALSE on failure.


This function can be called statically.


Using checkPort

require_once "Net_Portscan/Portscan.php";

if (
Net_Portscan::checkPort("localhost"80) == NET_PORTSCAN_SERVICE_FOUND) {
"There is a service on localhost on port 80 (" Net_Portscan::getService(80) . ").\n";
Net_Portscan (Previous) check for available services (Next)
Last updated: Sun, 04 Oct 2015 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:

User Notes:

There are no user contributed notes for this page.