当前位置: 首页>>代码示例>>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;未经允许,请勿转载。