Hprose\Client::setUri PHP Метод

setUri() защищенный Метод

protected setUri ( $uri )
    protected function setUri($uri)
    {
        $this->uri = $uri;
    }

Usage Example

Пример #1
0
 protected function setUri($uri)
 {
     parent::setUri($uri);
     $p = parse_url($uri);
     if ($p) {
         switch (strtolower($p['scheme'])) {
             case 'tcp':
             case 'tcp4':
                 $this->type = SWOOLE_SOCK_TCP;
                 $this->host = $p['host'];
                 $this->port = $p['port'];
                 break;
             case 'tcp6':
                 $this->type = SWOOLE_SOCK_TCP6;
                 $this->host = $p['host'];
                 $this->port = $p['port'];
                 break;
             case 'ssl':
             case 'sslv2':
             case 'sslv3':
             case 'tls':
                 $this->type = SWOOLE_SOCK_TCP | SWOOLE_SSL;
                 $this->host = $p['host'];
                 $this->port = $p['port'];
                 break;
             case 'unix':
                 $this->type = SWOOLE_UNIX_STREAM;
                 $this->host = $p['path'];
                 $this->port = 0;
                 break;
             default:
                 throw new Exception("Only support tcp, tcp4, tcp6 or unix scheme");
         }
         if (($this->type === SWOOLE_SOCK_TCP || $this->type === SWOOLE_SOCK_TCP | SWOOLE_SSL) && filter_var($this->host, FILTER_VALIDATE_IP) === false) {
             $ip = gethostbyname($this->host);
             if ($ip === $this->host) {
                 throw new Exception('DNS lookup failed');
             } else {
                 $this->host = $ip;
             }
         }
         $this->close();
     } else {
         throw new Exception("Can't parse this uri: " . $uri);
     }
 }
All Usage Examples Of Hprose\Client::setUri