Net_Portscan::checkPort()
Synopsis
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.
Parameter
-
string $host
- address of the host to check -
string $port
- port to check -
string $timeout
- time in seconds to wait for response from hostIf 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 thephp.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
<?php
require_once "Net_Portscan/Portscan.php";
if (Net_Portscan::checkPort("localhost", 80) == NET_PORTSCAN_SERVICE_FOUND) {
echo "There is a service on localhost on port 80 (" . Net_Portscan::getService(80) . ").\n";
}
?>