function checkServer($host, $port)
{
$host = gethostbyname($host);
$socket = @fsockopen($host, $port, $errno, $errstr, 0.6);
if ($socket)
{
fclose($socket);
return TRUE;
}
else
{
fclose($socket);
return FALSE;
}
}
$host = '127.0.0.1';
$port = '23073';
echo "server {$host}:{$port} is ";
if (checkServer($host, $port))
{
echo "ON";
}
else
{
echo "OFF";
}