0 Members and 1 Guest are viewing this topic.
<?php $ip = '222.239.79.38';$port = 23073; $start_time = microtime(true); $sock = socket_create(AF_INET,SOCK_DGRAM,SOL_UDP); socket_set_option($sock, SOL_SOCKET, SO_RCVTIMEO, array("sec" => 5, "usec" => 1)); // 5 Second timeout $packet = 'i'.chr(0); // Ping packet from Client -> Server (Lobby ping) socket_sendto($sock, $packet, strlen($packet), 0x100, $ip, $port); do {@socket_recvfrom($sock,$buffer,6,0,$ip,$port);} while(strlen($buffer) == 6); $total_time = round((microtime(true) - $start_time)*1000); socket_close($sock); if ($buffer == '') { echo "offline"; }else{ echo "online"; }?>
Additionally, your host may have built PHP without the --enable-sockets command line switch, so that command might possibly just not work.