public function Query()
 {
     $Length = StrLen($this->ServerIP);
     $Data = Pack('cccca*', HexDec($Length), 0, 0x4, $Length, $this->ServerIP) . Pack('nc', $this->ServerPort, 0x1);
     Socket_Send($this->Socket, $Data, StrLen($Data), 0);
     // handshake
     Socket_Send($this->Socket, "", 2, 0);
     // status ping
     $Length = $this->ReadVarInt();
     // full packet length
     if ($Length < 10) {
         return FALSE;
     }
     Socket_Read($this->Socket, 1);
     // packet type, in server ping it's 0
     $Length = $this->ReadVarInt();
     // string length
     $Data = Socket_Read($this->Socket, $Length, PHP_NORMAL_READ);
     // and finally the json string
     if ($Data === FALSE) {
         throw new MinecraftPingException('Server didn\'t return any data');
     }
     $Data = JSON_Decode($Data, true);
     if (JSON_Last_Error() !== JSON_ERROR_NONE) {
         if (Function_Exists('json_last_error_msg')) {
             throw new MinecraftPingException(JSON_Last_Error_Msg());
         } else {
             throw new MinecraftPingException('JSON parsing failed');
         }
         return FALSE;
     }
     return $Data;
 }
 private function CheckSession($Data)
 {
     $Data = JSON_Decode($Data, true);
     if (JSON_Last_Error() !== JSON_ERROR_NONE || !Array_Key_Exists('Status', $Data)) {
         return false;
     }
     return $Data['Status'] === 'OK';
 }