Sets the proxy

@param string       $host Proxy host
@param int          $port Proxy port
@param int optional $type Proxy type, defaults to HTTP

@return void
@throws \Exception
15272
public function setProxy($host, $port, $type = CURLPROXY_HTTP)
  {
    static $types_str = [
      'HTTP', 'SOCKS4', 'SOCKS5', 'SOCKS4A', 'SOCKS5_HOSTNAME'
    ];
    $types = [];
    foreach ($types_str as $type_str) {
      if (defined('CURLPROXY_' . $type_str)) {
        $types[] = constant('CURLPROXY_' . $type_str);
      }
    }
    if (! in_array($type, $types)) {
      throw new \Exception('Invalid proxy type specified.');
    }

    $this->_proxy['host'] = $host;
    $this->_proxy['port'] = (int) $port;
    $this->_proxy['type'] = $type;
  }
259858
def set_tunnel(self, host, port=None, headers=None):
        
        self._tunnel_host = host
        self._tunnel_port = port
        if headers:
            self._tunnel_headers = headers
        else:
            self._tunnel_headers.clear()
698128
public function connect($host, $port = 80, $secure = false)
    {
        // If no proxy is set, fall back to Socket adapter
        if (! $this->config['proxy_host']) return parent::connect($host, $port, $secure);

        // Go through a proxy - the connection is actually to the proxy server
        $host = $this->config['proxy_host'];
        $port = $this->config['proxy_port'];

        // If we are connected to the wrong proxy, disconnect first
        if (($this->connected_to[0] != $host || $this->connected_to[1] != $port)) {
            if (is_resource($this->socket)) $this->close();
        }

        // Now, if we are not connected, connect
        if (! is_resource($this->socket) || ! $this->config['keepalive']) {
            $this->socket = @fsockopen($host, $port, $errno, $errstr, (int) $this->config['timeout']);
            if (! $this->socket) {
                $this->close();
                require_once 'Zend/Http/Client/Adapter/Exception.php';
                throw new Zend_Http_Client_Adapter_Exception(
                    'Unable to Connect to proxy server ' . $host . ':' . $port . '. Error #' . $errno . ': ' . $errstr);
            }

            // Set the stream timeout
            if (!stream_set_timeout($this->socket, (int) $this->config['timeout'])) {
                require_once 'Zend/Http/Client/Adapter/Exception.php';
                throw new Zend_Http_Client_Adapter_Exception('Unable to set the connection timeout');
            }

            // Update connected_to
            $this->connected_to = array($host, $port);
        }
    }
632169
public function setPort($port)
        {
            if ($this->validatePort($port) === false) {
                throw new Exception("Port \"$port\" is not a valid HTTP port.");
            }

            $oldPort     = $this->_port;
            $this->_port = $port;

            return $oldPort;
        }
880921
public static function isPortOpen($host, $port, $protocol)
    {
        $protocol = strtolower($protocol);
        
        if ($protocol != 'tcp' && $protocol != 'udp')
        {
            $errMsg = 'Unrecognized protocol [' . $protocol . '] ' . 
                      'please specify [tcp] or [udp]';
            throw new \Exception($errMsg);
        }
        
        if (empty($host))
        {
            $host = self::getPublicIp();
        }

        foreach ($ports as $port)
        {
            $connection = @fsockopen($host, $port);

            if (is_resource($connection))
            {
                $isOpen = true;
                fclose($connection);
            }

            else
            {
                $isOpen = false;
            }
        }
        
        return $isOpen;
    }
988648
public static function setForcedHost($host = null)
    {
        if (! is_string($host) && ! is_null($host)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid host provided; must be an string or a null, "%s" received.',
                is_object($host) ? get_class($host) : gettype($host)
            ));
        }
        static::$forcedHost = $host;
    }
1158975
public function setServer($host, $port = 6379)
    {
        $this->host = $host;
        $this->port = $port ? $port : $this->port;
    }
631701
public function setPort($port)
    {
        if ($port != $this->_port) {
            $this->_port = (int)$port;
            $this->_hostInfo = null;
        }
        return $this;
    }
253334
public static function serve($host = '127.0.0.1', $port = 8000): void
    {
        static::stopServing();

        $server = new DuskServer($host, $port);
        $server->stash(['class' => static::class]);
        $server->start();

        static::$server = $server;
    }
1178696
public 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;
        if (is_int($port)) {
            if ($port) {
                $this->_port = $port;
            }
        }
        $this->_path = '';

        return $this;
    }
946536
public function init(string $scheme, string $host, int $port): self
    {
        return $this
            ->setServerOrigin($scheme, $host, $port)
            ->setPreFlightCacheMaxAge(0)
            ->setCredentialsNotSupported()
            ->enableAllOriginsAllowed()
            ->setAllowedOrigins([])
            ->enableAllMethodsAllowed()
            ->setAllowedMethods([])
            ->enableAllHeadersAllowed()
            ->setAllowedHeaders([])
            ->setExposedHeaders([])
            ->disableAddAllowedMethodsToPreFlightResponse()
            ->disableAddAllowedHeadersToPreFlightResponse()
            ->disableCheckHost();
    }
488053
function setProxy($proxyHost, $proxyPort) {
      $this->useProxy = true;
      $this->proxyHost = $proxyHost;
      $this->proxyPort = $proxyPort;
    }
375048
public static Proxy httpProxy(String host, int port) {
        return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(Objects.requireNonNull(host), port));
    }
1350372
public void setProxy(String proxyHost, int proxyPort) {
        System.setProperty("http.proxySet", "true");
        System.setProperty("http.proxyHost", proxyHost);
        System.setProperty("http.proxyPort", "" + proxyPort);
        System.setProperty("https.proxyHost", proxyHost);
        System.setProperty("https.proxyPort", "" + proxyPort);
    }
1358328
public function setProxy($ipNumber, $port, $user = '', $pass = '')
    {
        $this->proxyIP = $ipNumber;
        $this->proxyPORT = $port;
        $this->proxyUSER = $user;
        $this->proxyPASS = $pass;
    }
458144
public static void proxyPort(final int port) {
    final String portValue = Integer.toString(port);
    setProperty("http.proxyPort", portValue);
    setProperty("https.proxyPort", portValue);
  }
969347
def enable_proxy(self, host, port):
        """"""

        self.proxy = [host, _number(port)]
        self.proxy_enabled = True