I am working on a game server, however i can't procede because this hapens
<?php
$x = trim(fgets(STDIN));
class Client
{
public $id;
public $socketid;
public $name;
}
$port = 6112;
$socket = @socket_create_listen("6112");
socket_set_nonblock($socket);
$connectnom = 0;
echo "starting";
$connected = false;
while(true)
{
for($connectno = $connectnom; $connectno < 20;)
{
if(($clients[$clientupto] = socket_accept($socket)) !== false)
{
$connectno++;
echo "\nClient has connected\n";
$connectnom++;
$connected = true;
$socket = @socket_create_listen("6112");
socket_set_nonblock($socket);
echo "Started listening on socket";
break;
}
if($connected == true)
{
for($clientupto = 0; $clientupto < $connectno; $clientupto++)
{
fread($clients[$clientupto], 8192);
echo "listening";
if($recd == "<policy-file-request/>\n"){
$clientdata[$clientupto] = new Client;
echo "CP Client detected!";
fwrite($clients[$clientupto], "<cross-domain-policy><allow-access-from domain='*.clubpenguin.com' to-ports='6112' /><allow-access-from domain='*.critteroo.com' to-ports='6112' /></cross-domain-policy>" . chr(0));
$recd = fread($clients[$clientupto], 1024);
if($recd == "<msg t='sys'><body action='rndK' r='-1'></body></msg>" . chr(0)){
fwrite($clients[$clientupto], "<msg t='sys'><body action='rndK' r='-1'><k>kfQXLtx}LqMRjkEWbR</k></body></msg>\n");
}
if (stripos($recd, "<msg t='sys'><body action='login'")) {
$clientdata[$clientupto]->name = stribet("<msg t='sys'><body action='login' r='0'><login z='w1'><nick><![CDATA[", "]");
}
echo "Client data stored name $clientdata[$clientupto]->name";
$connected = false;
break;
}
}
}
}
}
?>
Invalid stream resource on line41.