當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CakeSocket::read方法代碼示例

本文整理匯總了PHP中CakeSocket::read方法的典型用法代碼示例。如果您正苦於以下問題:PHP CakeSocket::read方法的具體用法?PHP CakeSocket::read怎麽用?PHP CakeSocket::read使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CakeSocket的用法示例。


在下文中一共展示了CakeSocket::read方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _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

示例2: 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

示例3: 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


注:本文中的CakeSocket::read方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。