Fixed RCON non-blocking sockets

This commit is contained in:
Shoghi Cervantes Pueyo 2013-05-15 17:30:06 +02:00
parent 33bd66c1da
commit de5be4168d

View File

@ -48,7 +48,7 @@ class RCON{
console("[ERROR] RCON can't be started: ".socket_strerror(socket_last_error()));
return;
}
@socket_set_nonblock($this->socket);
@socket_set_block($this->socket);
for($n = 0; $n < $this->threads; ++$n){
$this->workers[$n] = new RCONInstance($this->socket, $this->password, $this->clientsPerThread);
}
@ -139,6 +139,10 @@ class RCONInstance extends Thread{
public function run(){
while($this->stop !== true){
usleep(1);
$r = array($socket = $this->socket);
$w = null;
$e = null;
if(socket_select($r, $w, $e, 0) === 1){
if(($client = socket_accept($this->socket)) !== false){
socket_set_block($client);
socket_set_option($client, SOL_SOCKET, SO_KEEPALIVE, 1);
@ -156,6 +160,7 @@ class RCONInstance extends Thread{
@socket_close($client);
}
}
}
for($n = 0; $n < $this->maxClients; ++$n){
$client = &$this->{"client".$n};