Queries the server and returns the servers information

@param string $host
@param number $port
16582
public static function query ($host = '127.0.0.1', $port = 25565) {
        // check if the host is in ipv4 format
        $host = filter_var($host, FILTER_VALIDATE_IP) ? $host : gethostbyname($host);
        
        $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
        if (! @socket_connect($socket, $host, $port)) {
            return false;
        }
        
        // create the handshake and ping packet
        $handshakePacket = new HandshakePacket($host, $port, 107, 1);
        $pingPacket = new PingPacket();
        
        $handshakePacket->send($socket);
        
        // high five
        $start = microtime(true);
        $pingPacket->send($socket);
        $length = self::readVarInt($socket);
        $ping = round((microtime(true) - $start) * 1000);
        
        // read the requested data
        $data = socket_read($socket, $length, PHP_NORMAL_READ);
        $data = strstr($data, '{');
        $data = json_decode($data);
        
        $descriptionRaw = isset($data->description) ? $data->description : false;
        $description = $descriptionRaw;
        
        // colorize the description if it is supported
        if (gettype($descriptionRaw) == 'object') {
            $description = '';
            
            if (isset($descriptionRaw->text)) {
                $color = isset($descriptionRaw->color) ? $descriptionRaw->color : '';
                $description = '<font color="' . $color . '">' . $descriptionRaw->text . '</font>';
            }
            
            if (isset($descriptionRaw->extra)) {
                foreach ($descriptionRaw->extra as $item) {
                    $description .= isset($item->bold) && $item->bold ? '<b>' : '';
                    $description .= isset($item->color) ? '<font color="' . $item->color . '">' . $item->text . '</font>' : '';
                    $description .= isset($item->bold) && $item->bold ? '</b>' : '';
                }
            }
        }
        
        return array(
                'hostname' => $host,
                'port' => $port,
                'ping' => $ping,
                'version' => isset($data->version->name) ? $data->version->name : false,
                'protocol' => isset($data->version->protocol) ? $data->version->protocol : false,
                'players' => isset($data->players->online) ? $data->players->online : false,
                'max_players' => isset($data->players->max) ? $data->players->max : false,
                'description' => $description,
                'description_raw' => $descriptionRaw,
                'favicon' => isset($data->favicon) ? $data->favicon : false,
                'modinfo' => isset($data->modinfo) ? $data->modinfo : false
        );
    }
231421
public static function getInstance($host = '127.0.0.1', $port = 11211)
    {
        return \Webiny\Component\Cache\Bridge\Memcache::getInstance($host, $port);
    }
189689
public function setDefaultHost($host, $port = null) {
		$this->defaultHost = (string) $host;
		
		if ($port !== null) {
			$this->setDefaultPort($port);
		}
		
		return $this;
	}
166082
public function getHost(bool $withPort = true) : string
  {
      // Check for proxy first
      if ($host = $this->server('HTTP_X_FORWARDED_HOST')) {
          $host = last(explode(',', $host));
      } elseif (!$host = $this->server('HTTP_HOST')) {
          if (!$host = $this->server('HTTP_SERVER_NAME')) {
              $host = $this->server('HTTP_SERVER_ADDR');
          }
      }

      // trim and remove port number from host
      // host is lowercase as per RFC 952/2181
      $host = strtolower(preg_replace('/:\d+$/', '', trim($host)));

      if (!$withPort) {
          return $host;
      }

      // Port number
      $scheme = $this->getHttpScheme();
      $port = $this->getPort();
      
      $appendPort = ':' . $port;

      // Don't append port number if a normal port.
      if (($scheme == 'http' && $port == '80') || ($scheme == 'https' && $port == '443')) {
          $appendPort = '';
      }

      return $host . $appendPort;
  }
63797
public function setPeername($host, $port)
    {
        $this->host = $host;
        $this->port = $port;
        $this->addr = '[' . $this->host . ']:' . $this->port;
        if ($this->pool->allowedClients !== null) {
            if (!TCP::netMatch($this->pool->allowedClients, $this->host)) {
                Daemon::log('Connection is not allowed (' . $this->host . ')');
                $this->ready = false;
                $this->finish();
            }
        }
    }
996615
protected function command($host, $port): string
    {
        $php = (new PhpExecutableFinder)->find(false);

        return vsprintf('%s -S %s:%s index.html', [
            $php, $host, $port,
        ]);
    }
831185
protected function getSocket($host, $port, $timeout)
    {
        return stream_socket_client("tcp://{$host}:{$port}", $error, $message, $timeout, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT);
    }
1241423
protected function _connect($host, $port)
    {
        $errorNum = 0;
        $errorStr = '';

        $remoteAddr = $this->_transport . '://' . $host . ':' . $port;

        if (!is_resource($this->_connection)) {
            $this->_connection = @stream_socket_client($remoteAddr, $errorNum, $errorStr, self::TIMEOUT);

            if ($this->_connection === false) {
                if ($errorNum == 0) {
                    throw new SMTPException(__('Unable to open socket. Unknown error'));
                } else {
                    throw new SMTPException(__('Unable to open socket. %s', array($errorStr)));
                }
            }

            if (@stream_set_timeout($this->_connection, self::TIMEOUT) === false) {
                throw new SMTPException(__('Unable to set timeout.'));
            }

            $this->helo();

            if ($this->_secure == 'tls') {
                $this->_tls();
            }

            if (($this->_user !== null) && ($this->_pass !== null)) {
                $this->_auth();
            }
        }
    }
1348747
public function setProxy($host = null, $port = null)
    {
        parent::setProxy($host, $port);

        if ($this->curl) {
            if ($this->proxyHost) {
                curl_setopt($this->curl, CURLOPT_PROXY, $this->proxyHost);
                curl_setopt($this->curl, CURLOPT_PROXYPORT, $this->proxyPort);
            } else {
                curl_setopt($this->curl, CURLOPT_PROXY, '');
            }
        }
    }
1031440
public static function is_port_open($host, $port)
	{
		$connection = @fsockopen($host, $port);
		if (is_resource($connection))
		{
			fclose($connection);
			return FALSE;
		}
		return TRUE;
	}
440633
public function getRequestServer($port = false, $protocol = false)
    {
        $servername = $this->getServerName();

        if ($port && $this->server('SERVER_PORT' !== false)) {
            $servername .= ':' . $this->server('SERVER_PORT');
        }

        if ($protocol) {
            $servername = (
                ($this->server('HTTPS') !== 'off'
                    || $this->server('SERVER_PORT') == 443) ? "https://" : "http://") . $servername
            ;
        }

        return $servername;
    }
880028
function SetServer ( $host, $port = 0 )
    {
        assert ( is_string($host) );
        if ( $host[0] == '/')
        {
            $this->_path = 'unix://' . $host;
            return;
        }
        if ( substr ( $host, 0, 7 )=="unix://" )
        {
            $this->_path = $host;
            return;
        }

        $this->_host = $host;
        $port = intval($port);
        assert ( 0<=$port && $port<65536 );
        $this->_port = ( $port==0 ) ? 9312 : $port;
        $this->_path = '';
    }
496231
public function connect($host = '127.0.0.1', $port = 21)
	{
		$errno = null;
		$err   = null;

		// If already connected, return
		if (\is_resource($this->conn))
		{
			return true;
		}

		// If native FTP support is enabled let's use it...
		if (FTP_NATIVE)
		{
			$this->conn = @ftp_connect($host, $port, $this->timeout);

			if ($this->conn === false)
			{
				throw new FilesystemException(sprintf('%1$s: Could not connect to host " %2$s " on port " %3$s "', __METHOD__, $host, $port));
			}

			// Set the timeout for this connection
			ftp_set_option($this->conn, FTP_TIMEOUT_SEC, $this->timeout);

			return true;
		}

		// Connect to the FTP server.
		$this->conn = @ fsockopen($host, $port, $errno, $err, $this->timeout);

		if (!$this->conn)
		{
			throw new FilesystemException(
				sprintf(
					'%1$s: Could not connect to host " %2$s " on port " %3$s ". Socket error number: %4$s and error message: %5$s',
					__METHOD__,
					$host,
					$port,
					$errno,
					$err
				)
			);
		}

		// Set the timeout for this connection
		socket_set_timeout($this->conn, $this->timeout, 0);

		// Check for welcome response code
		if (!$this->_verifyResponse(220))
		{
			throw new FilesystemException(sprintf('%1$s: Bad response. Server response: %2$s [Expected: 220]', __METHOD__, $this->response));
		}

		return true;
	}
4079
public function setServerParams($host, $port = 11211, $timeout = NULL, $retry_interval = false, $status = NULL, $failure_callback = NULL)
    {
    }
24500
protected function getConnectionString($hosts, $protocol, $port)
    {
        // Normalize hosts into an array.
        $hosts = is_array($hosts) ? $hosts : [$hosts];

        $hosts = array_map(function ($host) use ($protocol, $port) {
            return "{$protocol}{$host}:{$port}";
        }, $hosts);

        return implode(' ', $hosts);
    }
698683
public function launch($host, $port, $profile)
    {
        if ($this->logger) {
            $this->logger->info('Starting web socket');
        }

        $server = new Server("$host:$port", $this->loop);

        $app = new IoServer(
            $this->serverBuilder->buildMessageStack(),
            $server,
            $this->loop
        );

        // Server Event Loop to add other services in the same loop.
        $event = new ServerEvent($this->loop, $server, $profile);
        $this->eventDispatcher->dispatch(Events::SERVER_LAUNCHED, $event);

        if ($this->logger) {
            $this->logger->info(
                sprintf(
                    'Launching %s on %s PID: %s',
                    $this->getName(),
                    $host.':'.$port,
                    getmypid()
                )
            );
        }

        $app->run();
    }
519801
protected function _hasServer($host, $port)
    {
        $servers = $this->getServerList();
        foreach ($servers as $server) {
            if ($server['host'] === $host && $server['port'] === $port) {
                return true;
            }
        }

        return false;
    }