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

PHP CakeSocket类代码示例

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

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



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

示例1: getWorkers

 /**
  * Получение списка worker-ов
  *
  * @param string $worker имя воркеров, параметры которого нам нужно получить
  * @return array массив доступных worker-ов с их загрузкой и тд
  */
 public function getWorkers($worker = null)
 {
     // получаем статистику по worker-ам
     \App::uses('CakeSocket', 'Network');
     $Socket = new \CakeSocket($this->_config['server']);
     $Socket->connect();
     $workers = array();
     // делаем 2 замера с интервалом в 1 секунду для получение точного результата
     for ($i = 0; $i <= 2; $i++) {
         $Socket->write("status\n");
         $content = $Socket->read(50000);
         $answers = explode("\n", trim($content));
         foreach ($answers as $string) {
             $temp = explode("\t", $string);
             $title = trim($temp[0]);
             if (strpos($title, 'restart') !== false || strpos($title, '.') !== false) {
                 continue;
             }
             if (!empty($workers[$title])) {
                 // тут нас интересует только макс. значение доступных worker-ов
                 $workers[$title][3] = intval($workers[$title][3]) < intval($temp[3]) ? $temp[3] : $workers[$title][3];
             } else {
                 $workers[$title] = $temp;
             }
         }
         sleep(1);
     }
     $Socket->disconnect();
     return $worker ? $workers[$worker] : $workers;
 }
开发者ID:pdedkov,项目名称:cakephp-gearman,代码行数:36,代码来源:Manager.php


示例2: testReset

 /**
  * testReset method
  *
  * @return void
  */
 public function testReset()
 {
     $config = array('persistent' => true, 'host' => '127.0.0.1', 'protocol' => 'udp', 'port' => 80, 'timeout' => 20);
     $anotherSocket = new CakeSocket($config);
     $anotherSocket->reset();
     $this->assertEquals(array(), $anotherSocket->config);
 }
开发者ID:julkar9,项目名称:gss,代码行数:12,代码来源:CakeSocketTest.php


示例3: testConnectProtocolInHost

 /**
  * Test that protocol in the host doesn't cause cert errors.
  *
  * @return void
  */
 public function testConnectProtocolInHost()
 {
     $this->skipIf(!extension_loaded('openssl'), 'OpenSSL is not enabled cannot test SSL.');
     $configSslTls = array('host' => 'ssl://smtp.gmail.com', 'port' => 465, 'timeout' => 5);
     $socket = new CakeSocket($configSslTls);
     try {
         $socket->connect();
         $this->assertEquals('smtp.gmail.com', $socket->config['host']);
         $this->assertEquals('ssl', $socket->config['protocol']);
     } catch (SocketException $e) {
         $this->markTestSkipped('Cannot test network, skipping.');
     }
 }
开发者ID:tcyyky,项目名称:tel_practice_web,代码行数:18,代码来源:CakeSocketTest.php


示例4: _smtpSend

 /**
  * Protected method for sending data to SMTP connection
  *
  * @param string $data data to be sent to SMTP server
  * @param mixed $checkCode code to check for in server response, false to skip
  * @return void
  * @throws SocketException
  */
 protected function _smtpSend($data, $checkCode = '250')
 {
     if (!is_null($data)) {
         $this->_socket->write($data . "\r\n");
     }
     while ($checkCode !== false) {
         $response = '';
         $startTime = time();
         while (substr($response, -2) !== "\r\n" && time() - $startTime < $this->_config['timeout']) {
             $response .= $this->_socket->read();
         }
         if (substr($response, -2) !== "\r\n") {
             throw new SocketException(__d('cake_dev', 'SMTP timeout.'));
         }
         $responseLines = explode("\r\n", rtrim($response, "\r\n"));
         $response = end($responseLines);
         if (preg_match('/^(' . $checkCode . ')(.)/', $response, $code)) {
             if ($code[2] === '-') {
                 continue;
             }
             return $code[1];
         }
         throw new SocketException(__d('cake_dev', 'SMTP Error: %s', $response));
     }
 }
开发者ID:gilyaev,项目名称:framework-bench,代码行数:33,代码来源:SmtpTransport.php


示例5: connect

 /**
  * Connect
  *
  * @param string $host
  * @param integer $port
  * @return FtpSocket
  */
 public function connect($host = null, $port = null)
 {
     if (isset($host)) {
         $this->config['host'] = $host;
     }
     if (isset($port)) {
         $this->config['port'] = $port;
     }
     parent::connect();
     return $this;
 }
开发者ID:fotografde,项目名称:cakephp-ftp,代码行数:18,代码来源:FtpSocket.php


示例6: reset

 /**
  * Resets the state of this HttpSocket instance to it's initial state (before Object::__construct got executed) or does
  * the same thing partially for the request and the response property only.
  *
  * @param bool $full If set to false only HttpSocket::response and HttpSocket::request are reset
  * @return bool True on success
  */
 public function reset($full = true)
 {
     static $initalState = array();
     if (empty($initalState)) {
         $initalState = get_class_vars(__CLASS__);
     }
     if (!$full) {
         $this->request = $initalState['request'];
         $this->response = $initalState['response'];
         return true;
     }
     parent::reset($initalState);
     return true;
 }
开发者ID:mgoo,项目名称:MovieServer,代码行数:21,代码来源:HttpSocket.php


示例7: write

 public function write($data, $method = false, $size = 1024)
 {
     $didWrite = parent::write($data . $this->eol);
     if ($didWrite && $size > 0) {
         if ($method && is_callable(array($this, '_' . $method))) {
             $data = parent::read($size, $method);
             $method = '_' . $method;
             return $this->{$method}($data);
         }
         return parent::read($size);
     }
     return $didWrite;
 }
开发者ID:nani8124,项目名称:infinitas,代码行数:13,代码来源:EmailSocket.php


示例8: _disconnect

 /**
  * Disconnect
  *
  * @return void
  * @throws SocketException
  */
 protected function _disconnect()
 {
     $this->_smtpSend('QUIT', FALSE);
     $this->_socket->disconnect();
 }
开发者ID:mrbadao,项目名称:api-official,代码行数:11,代码来源:SmtpTransport.php


示例9: array

 /**
  * Build an HTTP Socket using the specified configuration.
  *
  * @param array $config	Configuration
  */
 function __construct($config = array())
 {
     if (is_string($config)) {
         $this->configUri($config);
     } elseif (is_array($config)) {
         $this->config = Set::merge($this->config, $config);
     }
     parent::__construct($this->config);
 }
开发者ID:kaz0636,项目名称:openflp,代码行数:14,代码来源:http_socket.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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