I'm trying to make an site using sockets, I've got a connection, and now I want to get data.
I've attempted but got the error:
I have no idea, but i tryed to take an example and alter it abit, doing so I got this:Warning: socket_read(): supplied resource is not a valid Socket resource in /users/silentdr/public_html/mjs-host/~neopuma/srvplayers.php on line 11
Code: Select all
<?php
$fp = fsockopen("IP REMOVED FOR SAFTEY", 3000, $errno, $errstr, 30);
if (!$fp) {
echo 'A error has occured - The server is currently offline!';
} else {
$data = socket_read($fp, 3000, PHP_NORMAL_READ);
$stats = explode("/", $data);
str_replace("-;", "", $stats[3]);
echo "Server: " .$stats[3]. " - Online - Players online: " .$stats[5]. "";
}
fclose($fp);
}
?>-Neo
p.s: It can take upto 20seconds for data to arrive - how can i keep it connected untill i recive data?