Re: Socket to query game servers
| From: | Logan | Date: | Wed, 23 Jan 2002 17:07:34 +0000 |
| Subject: | Re: Socket to query game servers | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-81715@lists.php.net to get a copy of this message | ||
I use the folowing code to query the status of Quake II Servers.
Everything goes rigth, if the server is up, but if it's down, there
isn´t no timeout for the socket and it dont stop opening the web.
There is one timeout for sockets??¿?, i didnt find it on the funtion
list.
Any idea about other to do the query?¿¿?¿
$recordset = mysql_query($query);
while ($row_demos=mysql_fetch_array($recordset))
{
$address = $row_demos["ip"];
$service_port = $row_demos["port"];
$socket = socket_create(AF_INET, SOCK_DGRAM, 0);
$result = socket_connect($socket, $address, $service_port);
if ($result < 0) {
echo "connect() failed.\nReason: ($result) \n";
}
$in = "ÿÿÿÿgetstatus";
socket_write($socket, $in, strlen($in));
$out = socket_read($socket, 512);