@param string $hostname

@return Client
962788
public function setHostname(string $hostname)
    {
        $this->hostname = $hostname;

        $this->raw = array_merge($this->raw, ['Hostname' => $hostname]);

        return $this;
    }
436592
public function get($serverName)
    {
        if (!isset($this->servers[$serverName])) {
            throw NoSuchServerException::forServerName($serverName);
        }

        return $this->servers[$serverName];
    }
1181509
public static function isHostnameIP($hostname)
  {
    // IP-literal: encased in square brackets
    // we match starting [ character followed by non ] characters followed by ] character as last character in hostname
    if(preg_match('/^\[[^\]]\]$/',$hostname)){
      // ok its an IP-literal, we do not parse the literal to see if its valid
      return true;
    }
    // IPv4 in decimal
    if(preg_match('/^[0-9]+$/',$hostname)){
      // ok its a number
      // lets see if its in the 32bit range
      $ip4_hex=base_convert($hostname, 10, 16);
      if(strlen($ip4_hex)<=8){
        // ok, hex representation is less than 9 chars, so thats max FFFFFFFF
        return true;
      }
    }
    $ip_parts=Array();
    if(!preg_match('/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/',$hostname,$ip_parts)){
      return false;
    }
    // check if each block is in byte range (hard to test with regex)
    for($j=1;$j<=4;$j++){
      if(($ip_parts[$j]>255) || ($ip_parts[$j]<0)){
        return false;
      }
    }
    return true;
  }
623031
public static function factory($host, $port, $sendTimeout = null, $receiveTimeout = null, $framedTransport = false)
    {
        $socket = self::createSocket($host, $port, $sendTimeout, $receiveTimeout);
        $transport = self::createTransport($socket, $framedTransport);
        $protocol = new TBinaryProtocolAccelerated($transport);
        $client = new RestClient($protocol);
        $transport->open();

        return $client;
    }
828691
public function equals(HostnameInterface $hostname): bool
    {
        return $this->getDomainParts() === $hostname->getDomainParts() && $this->getTld() === $hostname->getTld();
    }
342017
protected GitHubClient createClient(String hostname)
			throws MojoExecutionException {
		if (!hostname.contains("://"))
			return new RateLimitedGitHubClient(hostname);
		try {
			URL hostUrl = new URL(hostname);
			return new RateLimitedGitHubClient(hostUrl.getHost(), hostUrl.getPort(),
					hostUrl.getProtocol());
		} catch (MalformedURLException e) {
			throw new MojoExecutionException("Could not parse host URL "
					+ hostname, e);
		}
	}
693439
public static function getConnection( $hostname, $dbname ) {
		if ( isset( self::$dbConnections[ $hostname ] ) ) {
			$conn = self::$dbConnections[ $hostname ];
		} else {
			$section = new kfLogSection( __METHOD__ );
			try {
				$conn = new LoggedPDO(
					'mysql:host=' . $hostname . ';dbname=' . $dbname . '_p;charset=utf8',
					kfDbUsername(),
					kfDbPassword()
				);
			    $conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
			} catch ( Exception $e ) {
				throw new Exception( "Connection to '$hostname' failed: " . $e->getMessage() );
			}
			self::$dbConnections[ $hostname ] = $conn;
			return $conn;
		}

		// Re-used connection, switch database first.
		self::selectDB( $conn, $dbname );

		return $conn;
	}
883278
protected function buildHttpRequest($path, $hostname)
    {
        $r = array();
        $r[] = "GET {$path} HTTP/1.1";
        $r[] = "Host: {$hostname}";
        $r[] = "Connection: Close";
        $r[] = "User-Agent: HttpAdapter PHP-Library";
        $r[] = "\r\n";

        return implode("\r\n", $r);
    }
1118154
public function resourceFor($resourceName)
    {
        $resourceConfig = $this->config->resourceConfigurationFor($resourceName);

        return $this->newResource($resourceConfig);
    }
1173228
public function createSimpleHandler(string $channelName): SocketHandler
    {
        if (is_numeric($channelName)) {
            $host = '127.0.0.1';
            $port = $channelName;
        } else {
            list($host, $port) = explode(':', $channelName);
        }
        $timeout = in_array($host, ['localhost', '127.0.0.1']) ? 5 : 20;
        $peer = pfsockopen($host, (int) $port, $errno, $errstr, $timeout);
        if (!\is_resource($peer)) {
            throw new ConnectionException(
                sprintf(
                    'No Java server at %s:%s. Error message: %s (errno: %s)',
                    $host,
                    $port,
                    $errstr,
                    $errno
                )
            );
        }

        stream_set_timeout($peer, -1);
        $handler = new SocketHandler($this, new SocketChannelP($peer, $host, $this->java_recv_size, $this->java_send_size));
        $compatibility = PjbProxyClient::getInstance()->getCompatibilityOption($this->client);
        $this->write("\177$compatibility");
        $this->serverName = "$host:$port";

        return $handler;
    }
585458
private function fetchNews($hostname)
    {
        $source = $this->getOption('general/branding/news_source', 'https://news.bolt.cm/');
        $options = $this->fetchNewsOptions($hostname);

        $this->app['logger.system']->info('Fetching from remote server: ' . $source, ['event' => 'news']);

        try {
            $fetchedNewsData = (string) $this->app['guzzle.client']->get($source, $options)->getBody();
        } catch (RequestException $e) {
            $this->app['logger.system']->error(
                'Error occurred during newsfeed fetch',
                ['event' => 'exception', 'exception' => $e]
            );

            return [
                'error' => [
                    'type'   => 'error',
                    'title'  => 'Unable to fetch news!',
                    'teaser' => "<p>Unable to connect to $source</p>",
                ],
            ];
        }

        try {
            $fetchedNewsItems = Json::parse($fetchedNewsData);
        } catch (ParseException $e) {
            // Just move on, a user-friendly notice is returned below.
            $fetchedNewsItems = [];
        }

        $newsVariable = $this->getOption('general/branding/news_variable');
        if ($newsVariable && array_key_exists($newsVariable, $fetchedNewsItems)) {
            $fetchedNewsItems = $fetchedNewsItems[$newsVariable];
        }

        $news = [];

        // Iterate over the items, pick the first news-item that
        // applies and the first alert we need to show
        foreach ($fetchedNewsItems as $item) {
            $type = isset($item->type) ? $item->type : 'information';
            if (!isset($news[$type])
                && (empty($item->target_version) || Bolt\Version::compare($item->target_version, '>'))
            ) {
                $news[$type] = $item;
            }
        }

        if ($news) {
            return $news;
        }
        $this->app['logger.system']->error('Invalid JSON feed returned', ['event' => 'news']);

        return [
            'error' => [
                'type'   => 'error',
                'title'  => 'Unable to fetch news!',
                'teaser' => "<p>Invalid JSON feed returned by $source</p>",
            ],
        ];
    }
55673
public function getClient($name = null)
    {
        if (null === $name) {
            $name = $this->defaultClientName;
        }

        if (in_array($name, $this->getClientNames())) {
            return $this->clients[$name];
        }

        throw new \InvalidArgumentException(($name === null ? 'default client' : 'client ' . $name) . ' not configured');
    }
575632
public function setHostname($hostname = '')
    {
        $this->hostname = $hostname;
        $this->debug->debug(__FUNCTION__, 'setHostname: ' . json_encode($this->hostname));

        return $this;
    }
345306
public function make(array $config): Client
    {
        $config = $this->getConfig($config);

        return $this->getClient($config);
    }
956483
public static function getInstance($host = 'localhost', $port = 6379)
    {
        return \Webiny\Component\Cache\Bridge\Redis::getInstance($host, $port);
    }
1037846
private function createClient(
        string $host,
        int $httpPort,
        int $udpPort,
        string $user,
        string $password,
        bool $udp = false,
        bool $ssl = false,
        bool $sslVerify = false,
        float $timeout = 0.0,
        float $connectTimeout = 0.0
    ): Client {
        $client = new Client($host, $httpPort, $user, $password, $ssl, $sslVerify, $timeout, $connectTimeout);

        if ($udp) {
            $client->setDriver(new UDP($client->getHost(), $udpPort));
        }

        return $client;
    }
349783
private function fetchNewsOptions($hostname)
    {
        $driver = $this->app['db']->getDatabasePlatform()->getName();

        $options = [
            'query' => [
                'v'    => Bolt\Version::VERSION,
                'p'    => PHP_VERSION,
                'db'   => $driver,
                'name' => $hostname,
            ],
            'connect_timeout' => 5,
            'timeout'         => 10,
        ];

        if ($this->getOption('general/httpProxy')) {
            if ($this->getOption('general/httpProxy/user')) {
                $options['proxy'] = sprintf(
                    '%s:%s@%s',
                    $this->getOption('general/httpProxy/user'),
                    $this->getOption('general/httpProxy/password'),
                    $this->getOption('general/httpProxy/host')
                );
            } else {
                $options['proxy'] = $this->getOption('general/httpProxy/host');
            }
        }

        return $options;
    }