try this:
<?php
$fp = fsockopen("udp://euclid", 27015);
socket_set_timeout($fp, 1);
$contents = fread($fp, 1);
if($contents) {
echo "status on";
}
else {
echo "status off";
}
?>
basically it tries to read something from the server with a timeout of 1 second. You can reduce this by setting the millisecond to something and the second to 0:
socket_set_timeout($fd, 0, 100); // 100 ms
but 1 second is good since if there is a lag or delay, it won't timeout very fast.
i've never dealt with CS servers, but do they usually print a message or any data upon connection? if so, the above should work 🙂
-sridhar