protected function setUri($uri) { parent::setUri($uri); $p = parse_url($uri); if ($p) { switch (strtolower($p['scheme'])) { case 'ws': $this->host = $p['host']; $this->port = isset($p['port']) ? $p['port'] : 80; $this->path = isset($p['path']) ? $p['path'] : '/'; $this->ssl = false; break; case 'wss': $this->host = $p['host']; $this->port = isset($p['port']) ? $p['port'] : 443; $this->path = isset($p['path']) ? $p['path'] : '/'; $this->ssl = true; break; default: throw new Exception("Only support ws and wss scheme"); } } else { throw new Exception("Can't parse this uri: " . $uri); } $this->header['Host'] = $this->host; $this->header['Connection'] = $this->keepAlive ? 'keep-alive' : 'close'; if ($this->keepAlive) { $this->header['Keep-Ailve'] = $this->keepAliveTimeout; } if (filter_var($this->host, FILTER_VALIDATE_IP) === false) { $ip = gethostbyname($this->host); if ($ip === $this->host) { throw new Exception('DNS lookup failed'); } else { $this->ip = $ip; } } else { $this->ip = $this->host; } }
<?php require_once "../../../vendor/autoload.php"; require_once '../CompressFilter.php'; require_once '../SizeFilter.php'; require_once '../StatFilter.php'; use Hprose\Client; $client = Client::create('tcp://127.0.0.1:1143/', false); $client->addFilter(new StatFilter()); $client->addFilter(new SizeFilter('Non compressed')); $client->addFilter(new CompressFilter()); $client->addFilter(new SizeFilter('Compressed')); $client->addFilter(new StatFilter()); $value = range(0, 99999); var_dump(count($client->echo($value)));
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); } }
<?php require_once "../../vendor/autoload.php"; use Hprose\Client; use Hprose\InvokeSettings; use Hprose\ResultMode; $client = Client::create('http://hprose.com/example/', false); var_dump($client->hello("World", new InvokeSettings(array('mode' => ResultMode::Normal)))); var_dump($client->hello("World", new InvokeSettings(array('mode' => ResultMode::Serialized)))); var_dump($client->hello("World", new InvokeSettings(array('mode' => ResultMode::Raw)))); var_dump($client->hello("World", new InvokeSettings(array('mode' => ResultMode::RawWithEndTag))));
public function useService($url = '', $namespace = '') { $this->initUrl($url); return parent::useService($url, $namespace); }
public function __construct($uris = null, $async = true) { parent::__construct($uris, $async); $this->hdtrans = new HalfDuplexTransporter($this, $async); $this->fdtrans = new FullDuplexTransporter($this, $async); }
protected function setUri($uri) { parent::setUri($uri); $url = parse_url($uri); $this->secure = strtolower($url['scheme']) == 'https'; $this->host = strtolower($url['host']); $this->path = isset($url['path']) ? $url['path'] : "/"; $this->keepAlive = true; $this->keepAliveTimeout = 300; }