• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP TSocket类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中TSocket的典型用法代码示例。如果您正苦于以下问题:PHP TSocket类的具体用法?PHP TSocket怎么用?PHP TSocket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TSocket类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct($keyspace, $server, $credentials, $framed_transport, $send_timeout, $recv_timeout)
 {
     $host = $server['host'];
     $port = $server['port'];
     $socket = new TSocket($host, $port);
     if ($send_timeout) {
         $socket->setSendTimeout($send_timeout);
     }
     if ($recv_timeout) {
         $socket->setRecvTimeout($recv_timeout);
     }
     if ($framed_transport) {
         $transport = new TFramedTransport($socket, true, true);
     } else {
         $transport = new TBufferedTransport($socket, 1024, 1024);
     }
     $client = new CassandraClient(new TBinaryProtocolAccelerated($transport));
     $transport->open();
     # TODO check API major version match
     $server_version = explode(".", $client->describe_version());
     $server_version = $server_version[0];
     if ($server_version < self::LOWEST_COMPATIBLE_VERSION) {
         $ver = self::LOWEST_COMPATIBLE_VERSION;
         throw new IncompatbleAPIException("The server's API version is too " . "low to be comptible with phpcassa (server: {$server_version}, " . "lowest compatible version: {$ver})");
     }
     $client->set_keyspace($keyspace);
     if ($credentials) {
         $request = cassandra_AuthenticationRequest($credentials);
         $client->login($request);
     }
     $this->keyspace = $keyspace;
     $this->client = $client;
     $this->transport = $transport;
 }
开发者ID:htmlgraphic,项目名称:HTMLgraphic-MVC,代码行数:34,代码来源:connection.php


示例2: __construct

 public function __construct($keyspace, $server, $credentials = null, $framed_transport = True, $send_timeout = null, $recv_timeout = null)
 {
     $this->server = $server;
     $server = explode(':', $server);
     $host = $server[0];
     if (count($server) == 2) {
         $port = (int) $server[1];
     } else {
         $port = self::DEFAULT_PORT;
     }
     $socket = new \TSocket($host, $port);
     if ($send_timeout) {
         $socket->setSendTimeout($send_timeout);
     }
     if ($recv_timeout) {
         $socket->setRecvTimeout($recv_timeout);
     }
     if ($framed_transport) {
         $transport = new \TFramedTransport($socket, true, true);
     } else {
         $transport = new \TBufferedTransport($socket, 1024, 1024);
     }
     $this->client = new CassandraClient(new \TBinaryProtocolAccelerated($transport));
     $transport->open();
     $this->set_keyspace($keyspace);
     if ($credentials) {
         $request = new AuthenticationRequest(array("credentials" => $credentials));
         $this->client->login($request);
     }
     $this->keyspace = $keyspace;
     $this->transport = $transport;
     $this->op_count = 0;
 }
开发者ID:codewinguagua,项目名称:Cassandra-Cluster-Admin,代码行数:33,代码来源:ConnectionWrapper.php


示例3: __get

 public function __get($name)
 {
     if (isset($this->services[$name])) {
         if (is_string($this->services[$name])) {
             if (isset($this->service_config[$name])) {
                 $config = $this->service_config[$name];
                 if (empty($config['send_timeout'])) {
                     $config['send_timeout'] = $this->send_timeout;
                 }
                 if (empty($config['recv_timeout'])) {
                     $config['recv_timeout'] = $this->recv_timeout;
                 }
                 $transport = new TSocket($config['server_host'], $config['server_port']);
                 $transport->setSendTimeout($config['send_timeout'] * 1000);
                 $transport->setRecvTimeout($config['recv_timeout'] * 1000);
                 $transport->open();
                 $protocol = new TBinaryProtocol(new TBufferedTransport($transport));
                 $class = $this->services[$name];
                 $this->services[$name] = new $class($protocol);
             } else {
                 $transport = new TSocket($this->server_host, $this->server_port);
                 $transport->setSendTimeout($this->send_timeout * 1000);
                 $transport->setRecvTimeout($this->recv_timeout * 1000);
                 $transport->open();
                 $protocol = new TBinaryProtocol(new TBufferedTransport($transport));
                 $class = $this->services[$name];
                 $this->services[$name] = new $class($protocol);
             }
         }
         return $this->services[$name];
     } else {
         throw new Exception('Service Not Defined');
     }
 }
开发者ID:wheatma,项目名称:react_study,代码行数:34,代码来源:ThriftClient.php


示例4: __construct

 public function __construct($keyspace, $server, $credentials, $framed_transport, $send_timeout, $recv_timeout)
 {
     $host = $server['host'];
     $port = $server['port'];
     $socket = new TSocket($host, $port);
     if ($send_timeout) {
         $socket->setSendTimeout($send_timeout);
     }
     if ($recv_timeout) {
         $socket->setRecvTimeout($recv_timeout);
     }
     if ($framed_transport) {
         $transport = new TFramedTransport($socket, true, true);
     } else {
         $transport = new TBufferedTransport($socket, 1024, 1024);
     }
     $client = new CassandraClient(new TBinaryProtocolAccelerated($transport));
     $transport->open();
     # TODO check API major version match
     $client->set_keyspace($keyspace);
     if ($credentials) {
         $request = cassandra_AuthenticationRequest($credentials);
         $client->login($request);
     }
     $this->keyspace = $keyspace;
     $this->client = $client;
     $this->transport = $transport;
 }
开发者ID:karlhiramoto,项目名称:phpcassa,代码行数:28,代码来源:connection.php


示例5: getAiravataClient

    public function getAiravataClient()
    {
        $transport = new TSocket($this->airavataServerHost, $this->airavataServerPort);
        $protocol = new TBinaryProtocol($transport);
	$transport->open();
        return new AiravataClient($protocol);
    }
开发者ID:sanyaade-iot,项目名称:airavata-php-gateway,代码行数:7,代码来源:AiravataClientFactory.php


示例6: add_node

 public static function add_node($host, $port = self::DEFAULT_THRIFT_PORT, $framed_transport = false, $send_timeout = null, $recv_timeout = null, $persist = false)
 {
     try {
         // Create Thrift transport and binary protocol cassandra client
         $socket = new TSocket($host, $port, $persist);
         if ($send_timeout) {
             $socket->setSendTimeout($send_timeout);
         }
         if ($recv_timeout) {
             $socket->setRecvTimeout($recv_timeout);
         }
         if ($framed_transport) {
             $transport = new TFramedTransport($socket, true, true);
         } else {
             $transport = new TBufferedTransport($socket, 1024, 1024);
         }
         $client = new CassandraClient(new TBinaryProtocolAccelerated($transport));
         // Store it in the connections
         self::$connections[] = array('transport' => $transport, 'client' => $client);
         // Done
         return TRUE;
     } catch (TException $tx) {
         self::$last_error = 'TException: ' . $tx->getMessage() . "\n";
     }
     return FALSE;
 }
开发者ID:hoan,项目名称:phpcassa,代码行数:26,代码来源:phpcassa.php


示例7: getConnector

 /**
  * Create connector object
  * @param array $config
  * @return TTransport
  */
 private static function getConnector($config)
 {
     $class = isset($config['class']) ? $config['class'] : '';
     $param = isset($config['param']) ? $config['param'] : array();
     switch ($class) {
         case 'THttpClient':
             if (!isset($param['host'])) {
                 throw new Exception('Bad Thrift transport config');
             }
             $host = $param['host'];
             $port = isset($param['port']) ? $param['port'] : 80;
             $uri = isset($param['uri']) ? $param['uri'] : '';
             $scheme = isset($param['scheme']) ? $param['scheme'] : 'http';
             $timeout = isset($param['timeout']) ? $param['timeout'] : null;
             $connector = new THttpClient($url, $port, $uri, $scheme);
             $connector->setTimeoutSecs($timeout);
             $parameters = sprintf('host = "%s", port = %d, uri = "%s", scheme = "%s", timeout = %d', $host, $port, $uri, $scheme, $timeout);
             break;
         case 'TMemoryBuffer':
             $buf = isset($param['buf']) ? $param['buf'] : '';
             $connector = new TMemoryBuffer($buf);
             $parameters = sprintf('buf = "%s"', $buf);
             break;
         case 'TPhpStream':
             if (!isset($param['mode'])) {
                 throw new Exception('Bad Thrift transport config');
             }
             $mode = $param['mode'];
             $connector = new TPhpStream($mode);
             $parameters = sprintf('mode = %d', $mode);
             break;
         case 'TSocket':
             $host = isset($param['host']) ? $param['host'] : 'localhost';
             $port = isset($param['port']) ? $param['port'] : 9090;
             $persist = isset($param['persist']) ? $param['persist'] : false;
             $send_timeout = isset($param['send_timeout']) ? $param['send_timeout'] : 100;
             $recv_timeout = isset($param['recv_timeout']) ? $param['recv_timeout'] : 750;
             $connector = new TSocket($host, $port, $persist);
             $connector->setSendTimeout($send_timeout);
             $connector->setRecvTimeout($recv_timeout);
             $parameters = sprintf('host = "%s", port = %d, persist = %s, send_timeout = %d, recv_timeout = %d', $host, $port, $persist ? 'true' : 'false', $send_timeout, $recv_timeout);
             break;
         case 'TSocketPool':
             $hosts = isset($param['hosts']) ? $param['hosts'] : array('localhost');
             $ports = isset($param['ports']) ? $param['ports'] : array(9090);
             $persist = isset($param['persist']) ? $param['persist'] : false;
             $send_timeout = isset($param['send_timeout']) ? $param['send_timeout'] : 100;
             $recv_timeout = isset($param['recv_timeout']) ? $param['recv_timeout'] : 750;
             $connector = new TSocketPool($hosts, $ports, $persist);
             $connector->setSendTimeout($send_timeout);
             $connector->setRecvTimeout($recv_timeout);
             $parameters = sprintf('hosts = ("%s"), ports = (%d), persist = %s, send_timeout = %d, recv_timeout = %d', implode('","', $hosts), implode('","', $ports), $persist ? 'true' : 'false', $send_timeout, $recv_timeout);
             break;
         default:
             throw new Exception('Unknown connector: ' . $class);
     }
     sfContext::getInstance()->getLogger()->info(sprintf('{sfThriftPlugin}Create %s connector with parameters: %s', $class, $parameters));
     return $connector;
 }
开发者ID:tomi77,项目名称:sfThriftPlugin,代码行数:64,代码来源:ThriftProtocolFactory.class.php


示例8: initialize

 public function initialize($param)
 {
     $this->host = $param['host'];
     $this->port = $param['port'];
     $socket = new \TSocket($this->host, $this->port);
     $socket->setSendTimeout(2000);
     $socket->setRecvTimeout(5000);
     $transport = new \TBufferedTransport($socket, 512, 512);
     $protocol = new \TBinaryProtocol($transport);
     $this->hbaseThriftClient = new \THBaseServiceClient($protocol);
     $transport->open();
 }
开发者ID:nedvisol,项目名称:phporm,代码行数:12,代码来源:HbaseClient.php


示例9: __construct

 function __construct($host, $port, $timeout_ms = 300000, $do_open = true)
 {
     $socket = new TSocket($host, $port);
     $socket->setSendTimeout($timeout_ms);
     $socket->setRecvTimeout($timeout_ms);
     $this->transport = new TFramedTransport($socket);
     $protocol = new TBinaryProtocol($this->transport);
     parent::__construct($protocol);
     if ($do_open) {
         $this->open();
     }
 }
开发者ID:kamoljan,项目名称:hypertable,代码行数:12,代码来源:ThriftClient.php


示例10: __construct

 function __construct($options)
 {
     $config = Zend_Registry::get('configuration');
     $this->socket = new TSocket($config->stdprofile->host, $config->stdprofile->port);
     $this->socket->setSendTimeout($this->sendTimeout);
     $this->socket->setRecvTimeout($this->recvTimeout);
     $this->transport = new TFramedTransport($this->socket);
     $this->protocol = new TBinaryProtocolAccelerated($this->transport);
     $this->client = new StdProfile2Service_RdClient($this->protocol);
     $this->_handle = new zcommon_OpHandle();
     $this->_handle->source = $config->stdprofile->source;
     $this->_handle->auth = $config->stdprofile->auth;
 }
开发者ID:utcuong3010,项目名称:vng,代码行数:13,代码来源:stdprofile.php


示例11: connect

 public static function connect($params = array())
 {
     self::$config = $params;
     // Initialize Thrift connection
     $socket = new \TSocket($params["server"], 9090);
     $socket->setSendTimeout(3000);
     $socket->setRecvTimeout(10000);
     $transport = new \TBufferedTransport($socket);
     $protocol = new \TBinaryProtocol($transport);
     $client = new \HbaseClient($protocol);
     $transport->open();
     self::$hbase = new ThriftHBaseClientWrapper($client);
 }
开发者ID:terry80504,项目名称:MySQL-HBase-SQLBridge,代码行数:13,代码来源:mmb.php


示例12: __construct

 private function __construct()
 {
     try {
         $socket = new TSocket('localhost', '9030');
         $socket->setRecvTimeout(50000);
         $this->transport = new TBufferedTransport($socket);
         $protocol = new TBinaryProtocol($this->transport);
         $this->client = new TedServiceClient($protocol);
         $this->transport->open();
     } catch (TException $tx) {
         // a general thrift exception, like no such server
         echo "ThriftException: " . $tx->getMessage() . "\r\n";
     }
 }
开发者ID:ted,项目名称:ted,代码行数:14,代码来源:client_support.php


示例13: connect

 private function connect()
 {
     try {
         $options = array('host' => '10.30.22.135', 'port' => 7114);
         $socket = new TSocket($options['host'], $options['port']);
         $socket->setSendTimeout(10000);
         $socket->setRecvTimeout(10000);
         $this->transport = new TFramedTransport($socket);
         $protocol = new TBinaryProtocol($this->transport);
         $this->client = new TTokenClient($protocol);
     } catch (Exception $e) {
         throw $e;
     }
 }
开发者ID:utcuong3010,项目名称:vng,代码行数:14,代码来源:TokenGenerator.php


示例14: __construct

 /**
  * Constructor.  Initialize the model object
  *
  * @param array $conf   The global config information
  */
 function __construct($conf)
 {
     $this->sql_database = null;
     $this->hive_database = null;
     if ($conf['database_type'] == 'mysql') {
         $this->sql_database = new medoo(array('database_type' => 'mysql', 'database_name' => $conf['default_schema'], 'server' => $conf['host'], 'port' => $conf['port'], 'username' => $conf['user'], 'password' => $conf['password']));
     }
     if ($conf['database_type'] == 'hive') {
         $transport = new TSocket($conf['host'], $conf['port']);
         $transport->setSendTimeout(600 * 1000);
         $transport->setRecvTimeout(600 * 1000);
         $this->hive_database = new ThriftHiveClientEx(new TBinaryProtocol($transport));
     }
 }
开发者ID:Adapp,项目名称:propagator,代码行数:19,代码来源:DatabaseWrapper.php


示例15: connect

 private function connect()
 {
     try {
         $config = $this->getConfig();
         $options = array('host' => $config->thrift->host, 'port' => $config->thrift->port);
         $socket = new TSocket($options['host'], $options['port']);
         $socket->setSendTimeout($config->thrift->timeout->send);
         $socket->setRecvTimeout($config->thrift->timeout->recv);
         $this->transport = new TFramedTransport($socket);
         $protocol = new TBinaryProtocol($this->transport);
         $this->client = new T_PaymentBOClient($protocol);
     } catch (Exception $e) {
         throw $e;
     }
 }
开发者ID:utcuong3010,项目名称:vng,代码行数:15,代码来源:MAC.php


示例16: accept

 public function accept($timeout = -1)
 {
     if ($timeout !== 0) {
         $client = stream_socket_accept($this->handle, $timeout);
     } else {
         $client = stream_socket_accept($this->handle, $timeout);
     }
     if (!\hacklib_cast_as_boolean($client)) {
         return null;
     }
     $socket = new TSocket();
     $socket->setHandle($client);
     $transport = new TBufferedTransport($socket, $this->send_buffer_size, $this->recv_buffer_size);
     return $transport;
 }
开发者ID:davidnasar,项目名称:fbthrift,代码行数:15,代码来源:TServerSocket.php


示例17: connect

 private function connect()
 {
     try {
         $config = Zend_Registry::get('appconf');
         $options = array('host' => $config->billing->host, 'port' => $config->billing->port);
         $socket = new TSocket($options['host'], $options['port']);
         $socket->setSendTimeout($config->billing->connection->sendtimeout);
         $socket->setRecvTimeout($config->billing->connection->recvtimeout);
         $this->transport = new TFramedTransport($socket);
         $protocol = new TBinaryProtocol($this->transport);
         $this->client = new TPaymentClient($protocol);
     } catch (Exception $e) {
         throw $e;
     }
 }
开发者ID:utcuong3010,项目名称:vng,代码行数:15,代码来源:Billing.php


示例18: connect

 private function connect()
 {
     try {
         $config = Zend_Registry::get('appconf');
         $options = array('host' => $config->token->host, 'port' => $config->token->port);
         /* $options = array('host'=>'10.199.18.36',
            'port'=>7114);*/
         $socket = new TSocket($options['host'], $options['port']);
         $socket->setSendTimeout($config->token->connection->sendtimeout);
         $socket->setRecvTimeout($config->token->connection->sendtimeout);
         $this->transport = new TFramedTransport($socket);
         $protocol = new TBinaryProtocol($this->transport);
         $this->client = new TTokenClient($protocol);
     } catch (Exception $e) {
         throw $e;
     }
 }
开发者ID:utcuong3010,项目名称:vng,代码行数:17,代码来源:TokenGenerator.php


示例19: connect

 private function connect()
 {
     try {
         //            $config = $this->getConfig();
         //            $options = array('host'=>$config->thrift->host,
         //                             'port'=>$config->thrift->port);
         $options = array('host' => '10.30.22.135', 'port' => 6161);
         $socket = new TSocket($options['host'], $options['port']);
         $socket->setSendTimeout(1000);
         $socket->setRecvTimeout(1000);
         $this->transport = new TFramedTransport($socket);
         $protocol = new TBinaryProtocol($this->transport);
         $this->client = new TPaymentClient($protocol);
     } catch (Exception $e) {
         throw $e;
     }
 }
开发者ID:utcuong3010,项目名称:vng,代码行数:17,代码来源:Billing.php


示例20: accept

 public function accept($timeout = -1)
 {
     if ($timeout !== 0) {
         $client = stream_socket_accept($this->handle, $timeout);
     } else {
         $client = @stream_socket_accept($this->handle, $timeout);
     }
     if (!$client) {
         return false;
     }
     $socket = new TSocket();
     $socket->setHandle($client);
     // We need to create a buffered transport because TSocket's isReadable
     // is not reliable in PHP (hphp is fine) and buffered transport is more
     // efficient (60% faster in my tests)
     $transport = new TBufferedTransport($socket, $this->send_buffer_size, $this->recv_buffer_size);
     return $transport;
 }
开发者ID:jamescarr,项目名称:fbthrift,代码行数:18,代码来源:TServerSocket.php



注:本文中的TSocket类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP TTDate类代码示例发布时间:2022-05-23
下一篇:
PHP TSession类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap