This is the code i made a long time ago.
http://php.net/manual/en/function.fread.phpPHP Code:
$errno = $errstr = null;
$cmd = "\xFF\xFF\xFF\xFFgetstatus";
$f = fsockopen('udp://' . $ip, $port, $errno, $errstr, $timeout);
if (!$f)
die ("Unable to connect. Error $errno - $errstr\n");
socket_set_timeout ($f, 1, 0);
fwrite ($f, $cmd);
$data = '';
while ($d = fread ($f, 10000)) {
$data .= $d;
}
fclose ($f);