本文整理汇总了PHP中TSocket::setRecvTimeout方法的典型用法代码示例。如果您正苦于以下问题:PHP TSocket::setRecvTimeout方法的具体用法?PHP TSocket::setRecvTimeout怎么用?PHP TSocket::setRecvTimeout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TSocket
的用法示例。
在下文中一共展示了TSocket::setRecvTimeout方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: TSocket
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;
}
示例2: __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;
}
示例3: __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;
}
示例4: __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;
}
示例5: __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');
}
}
示例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;
}
示例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;
}
示例8: TSocket
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();
}
}
示例9: 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();
}
示例10: 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);
}
示例11: 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;
}
}
示例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";
}
}
示例13: medoo
/**
* 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));
}
}
示例14: 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;
}
}
示例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;
}
}