當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Http_Client_Adapter_Socket::connect方法代碼示例

本文整理匯總了PHP中Zend_Http_Client_Adapter_Socket::connect方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Http_Client_Adapter_Socket::connect方法的具體用法?PHP Zend_Http_Client_Adapter_Socket::connect怎麽用?PHP Zend_Http_Client_Adapter_Socket::connect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Http_Client_Adapter_Socket的用法示例。


在下文中一共展示了Zend_Http_Client_Adapter_Socket::connect方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: connect

 /**
  * Connect to the remote server
  *
  * Will try to connect to the proxy server. If no proxy was set, will
  * fall back to the target server (behave like regular Socket adapter)
  *
  * @param string  $host
  * @param int     $port
  * @param boolean $secure
  * @param int     $timeout
  */
 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);
     }
 }
開發者ID:Orchild,項目名稱:mt,代碼行數:43,代碼來源:Proxy.php

示例2: connect

 public function connect($host, $port = 80, $secure = false)
 {
     if (!isset($this->_ips[$host])) {
         $this->_ips[$host] = gethostbyname($host);
     }
     $this->_ip = $this->_ips[$host];
     return parent::connect($this->_ip, $port, $secure);
 }
開發者ID:Tony133,項目名稱:zf-web,代碼行數:8,代碼來源:SocketWithDnsCache.php

示例3: connect

 /**
  * Connect to the remote server
  *
  * Will try to connect to the proxy server. If no proxy was set, will
  * fall back to the target server (behave like regular Socket adapter)
  *
  * @param string  $host
  * @param int     $port
  * @param boolean $secure
  */
 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);
     }
     // Connect (a non-secure connection) to the proxy server
     return parent::connect($this->config['proxy_host'], $this->config['proxy_port'], false);
 }
開發者ID:DBezemer,項目名稱:server,代碼行數:19,代碼來源:Proxy.php

示例4: connect

 /**
  * Connect to the remote server
  *
  * Will try to connect to the proxy server. If no proxy was set, will
  * fall back to the target server (behave like regular Socket adapter)
  *
  * @param string  $host
  * @param int     $port
  * @param boolean $secure
  */
 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);
     }
     /* Url might require stream context even if proxy connection doesn't */
     if ($secure) {
         $this->config['sslusecontext'] = true;
     }
     // Connect (a non-secure connection) to the proxy server
     return parent::connect($this->config['proxy_host'], $this->config['proxy_port'], false);
 }
開發者ID:namgiangle90,項目名稱:tokyobaito,代碼行數:23,代碼來源:Proxy.php

示例5: connect

 /**
  * Connect to the remote server
  *
  * @param string $host   Host name
  * @param int    $port   Port number
  * @param bool   $secure Secure flag
  *
  * @return void
  */
 public function connect($host, $port = 80, $secure = false)
 {
     if (Mage::app()->useCache(self::CACHE_TYPE)) {
         $mode = $this->getConfigData('cache_mode');
         if (!($mode == PedroTeixeira_Correios_Model_Source_CacheMode::MODE_CACHE_ONLY)) {
             try {
                 parent::connect($host, $port, $secure);
             } catch (Zend_Http_Client_Adapter_Exception $e) {
                 Mage::log("{$this->_code} [socket]: {$e->getMessage()}");
             }
         }
     } else {
         parent::connect($host, $port, $secure);
     }
 }
開發者ID:reginaldojunior,項目名稱:correios-1,代碼行數:24,代碼來源:Socket.php

示例6: connect

 /**
  * Connect to the remote server
  *
  * @param string  $host
  * @param int     $port
  * @param boolean $secure
  * @param int     $timeout
  */
 public function connect($host, $port = 80, $secure = false)
 {
     $this->log("Connecting to: {$host}:{$port}");
     return parent::connect($host, $port, $secure);
 }
開發者ID:madberry,項目名稱:WhiteLabelTransfer,代碼行數:13,代碼來源:LoggingHttpClientAdapterSocket.php


注:本文中的Zend_Http_Client_Adapter_Socket::connect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。