Labdien!
Man lūk ir šāds skripts:
<?php
$ip = "127.0.0.1";
$ports = "27051";
$socket = fsockopen("udp://".$ip, $ports);
$cmd = "\xFF\xFF\xFF\xFF\x54Source Engine Query\x00";
$lenght = strlen($cmd);
fwrite($socket, $cmd, $lenght);
$response = fread($socket, 1);
if (!empty($response))
{
echo "<center><p style=\"font-size: 12px Tahoma; font-weight: bold; color: #00FF00;\">Online</p></center>";
} else
{
echo "<center><p style=\"font-size: 12px Tahoma; font-weight: bold; color: #ff4400;\">Offline</p></center>";
}
?>
Viņš pārbauda, vai norādītais ports eksistē.
Problēma tāda, ja ports neeksistē jeb process ir offline, tad viņš ļoti ilgi viņu lādē, apmēram minūti.
Kad ports eksistē jeb process ir online, tad viņš monemtāli viņu pārbauda.
Ko skriptam vajadzētu samainīt, lai viņš momentāli arī pārbaudītu, kad process ir offline?