public function Open()
 {
     if (!$this->RconSocket) {
         $this->RconSocket = @FSockOpen($this->Socket->Ip, $this->Socket->Port, $ErrNo, $ErrStr, $this->Socket->Timeout);
         if ($ErrNo || !$this->RconSocket) {
             throw new TimeoutException('Can\'t connect to RCON server: ' . $ErrStr, TimeoutException::TIMEOUT_CONNECT);
         }
         Stream_Set_Timeout($this->RconSocket, $this->Socket->Timeout);
         Stream_Set_Blocking($this->RconSocket, true);
     }
 }
Exemple #2
0
 public function Open()
 {
     if (!$this->RconSocket && $this->Socket->Engine == CI_SourceQuery::SOURCE) {
         $this->RconSocket = @FSockOpen($this->Socket->Ip, $this->Socket->Port, $ErrNo, $ErrStr, $this->Socket->Timeout);
         if ($ErrNo || !$this->RconSocket) {
             throw new SourceQueryException('Can\'t connect to RCON server: ' . $ErrStr);
         }
         Stream_Set_Timeout($this->RconSocket, $this->Socket->Timeout);
         Stream_Set_Blocking($this->RconSocket, true);
     }
 }
 public function Open()
 {
     if (!$this->RconSocket) {
         $this->RconSocket = @FSockOpen($this->Socket->Address, $this->Socket->Port, $ErrNo, $ErrStr, $this->Socket->Timeout);
         if ($ErrNo || !$this->RconSocket) {
             throw new SocketException('Can\'t connect to RCON server: ' . $ErrStr, SocketException::CONNECTION_FAILED);
         }
         Stream_Set_Timeout($this->RconSocket, $this->Socket->Timeout);
         Stream_Set_Blocking($this->RconSocket, true);
     }
 }
Exemple #4
0
 public function Open($Address, $Port, $Timeout, $Engine)
 {
     $this->Timeout = $Timeout;
     $this->Engine = $Engine;
     $this->Port = $Port;
     $this->Address = $Address;
     $this->Socket = @FSockOpen('udp://' . $Address, $Port, $ErrNo, $ErrStr, $Timeout);
     if ($ErrNo || $this->Socket === false) {
         throw new SocketException('Could not create socket: ' . $ErrStr, SocketException::COULD_NOT_CREATE_SOCKET);
     }
     Stream_Set_Timeout($this->Socket, $Timeout);
     Stream_Set_Blocking($this->Socket, true);
 }
Exemple #5
0
 public function Open($Ip, $Port, $Timeout, $Engine)
 {
     $this->Timeout = $Timeout;
     $this->Engine = $Engine;
     $this->Port = $Port;
     $this->Ip = $Ip;
     $this->Socket = @FSockOpen('udp://' . $Ip, $Port, $ErrNo, $ErrStr, $Timeout);
     if ($ErrNo || $this->Socket === false) {
         throw new Exception('Could not create socket: ' . $ErrStr);
     }
     Stream_Set_Timeout($this->Socket, $Timeout);
     Stream_Set_Blocking($this->Socket, true);
     return true;
 }
 public function Connect($Ip, $Port = 25565, $Timeout = 3)
 {
     if (!is_int($Timeout) || $Timeout < 0) {
         throw new InvalidArgumentException('Timeout must be an integer.');
     }
     $this->Socket = @FSockOpen('udp://' . $Ip, (int) $Port, $ErrNo, $ErrStr, $Timeout);
     if ($ErrNo || $this->Socket === false) {
         throw new MinecraftQueryException('Could not create socket: ' . $ErrStr);
     }
     Stream_Set_Timeout($this->Socket, $Timeout);
     Stream_Set_Blocking($this->Socket, true);
     try {
         $Challenge = $this->GetChallenge();
         $this->GetStatus($Challenge);
     } catch (MinecraftQueryException $e) {
         FClose($this->Socket);
         throw new MinecraftQueryException($e->getMessage());
     }
     FClose($this->Socket);
 }