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

PHP SimpleSocket类代码示例

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

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



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

示例1: invoke

 function invoke($method)
 {
     ob_start();
     parent::invoke($method);
     $output = ob_get_contents();
     ob_end_clean();
     $sock = new SimpleSocket("127.0.0.1", $this->_port, 5);
     $sock->write($output);
     $sock->close();
     echo $sock->getError();
 }
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:11,代码来源:eclipse.php


示例2: testSocket

 function testSocket()
 {
     $socket = new SimpleSocket("www.lastcraft.com", 80);
     $this->assertFalse($socket->isError(), "Error [" . $socket->getError() . "]");
     $this->assertTrue($socket->isOpen());
     $this->assertTrue($socket->write("GET www.lastcraft.com/test/network_confirm.php HTTP/1.0\r\n"));
     $socket->write("Host: localhost\r\n");
     $socket->write("Connection: close\r\n\r\n");
     $this->assertEqual($socket->read(8), "HTTP/1.1");
     $socket->close();
     $this->assertEqual($socket->read(8), "");
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:12,代码来源:live_test.php


示例3: testRecordOfSentCharacters

 public function testRecordOfSentCharacters()
 {
     $socket = new SimpleSocket('www.lastcraft.com', 80, 15);
     $this->assertTrue($socket->write("GET /test/network_confirm.php HTTP/1.0\r\n"));
     $socket->write("Host: www.lastcraft.com\r\n");
     $socket->write("Connection: close\r\n\r\n");
     $socket->close();
     $this->assertEqual($socket->getSent(), "GET /test/network_confirm.php HTTP/1.0\r\n" . "Host: www.lastcraft.com\r\n" . "Connection: close\r\n\r\n");
 }
开发者ID:Clansuite,项目名称:Clansuite,代码行数:9,代码来源:live_test.php


示例4: testRecordOfSentCharacters

 public function testRecordOfSentCharacters()
 {
     $socket = new SimpleSocket($this->host, $this->port, 15);
     $this->assertTrue($socket->write("GET /network_confirm.php HTTP/1.0\r\n"));
     $socket->write("Host: {$this->host}\r\n");
     $socket->write("Connection: close\r\n\r\n");
     $socket->close();
     $this->assertEqual($socket->getSent(), "GET /network_confirm.php HTTP/1.0\r\n" . "Host: {$this->host}\r\n" . "Connection: close\r\n\r\n");
 }
开发者ID:simpletest,项目名称:simpletest,代码行数:9,代码来源:live_test.php


示例5: testRecordOfSentCharacters

 function testRecordOfSentCharacters()
 {
     $site = $this->getServerInfo();
     $socket = new SimpleSocket($site['host'], $site['port'], 15);
     $this->assertTrue($socket->write("GET {$site['path']}network_confirm.php HTTP/1.0\r\n"));
     $socket->write("Host: {$site['host']}\r\n");
     $socket->write("Connection: close\r\n\r\n");
     $socket->close();
     $this->assertEqual($socket->getSent(), "GET {$site['path']}network_confirm.php HTTP/1.0\r\n" . "Host: {$site['host']}\r\n" . "Connection: close\r\n\r\n");
 }
开发者ID:GerHobbelt,项目名称:simpletest,代码行数:10,代码来源:live_test.php


示例6: while

 /**
  *    Reads the whole of the socket output into a
  *    single string.
  *    @param SimpleSocket $socket  Unread socket.
  *    @return string               Raw output if successful
  *                                 else false.
  *    @access private
  */
 function _readAll(&$socket)
 {
     $all = '';
     while (!$this->_isLastPacket($next = $socket->read())) {
         $all .= $next;
     }
     return $all;
 }
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:16,代码来源:http.php


示例7: readAll

 /**
  *    Reads the whole of the socket output into a
  *    single string.
  *    @param SimpleSocket $socket  Unread socket.
  *    @return string               Raw output if successful
  *                                 else false.
  *    @access private
  */
 protected function readAll($socket)
 {
     $all = '';
     while (!$this->isLastPacket($next = $socket->read())) {
         $all .= $next;
     }
     return $all;
 }
开发者ID:reevoo,项目名称:reevoomark-php-api,代码行数:16,代码来源:http.php


示例8: writeTo

 /**
  *    Dispatches the form data down the socket.
  *    @param SimpleSocket $socket        Socket to write to.
  *    @access public
  */
 function writeTo(&$socket)
 {
     $socket->write($this->encode());
 }
开发者ID:googlecode-mirror,项目名称:bulldoc,代码行数:9,代码来源:encoding.php


示例9: collectWorkerResults

 /**
  * Collects the results form the workers and processes any pending signals
  * @param int $sec timeout to wait for new results from the workers
  * @throws WorkerPoolException
  */
 protected function collectWorkerResults($sec = 0)
 {
     // dispatch signals
     pcntl_signal_dispatch();
     if (isset($this->workerProcesses) === FALSE) {
         throw new WorkerPoolException('There is no list of worker processes. Maybe you destroyed the worker pool?', 1401179881);
     }
     $result = SimpleSocket::select($this->workerProcesses->getSockets(), array(), array(), $sec);
     foreach ($result['read'] as $socket) {
         /** @var $socket SimpleSocket */
         $processId = $socket->annotation['pid'];
         $result = $socket->receive();
         $possibleArrayKeys = array('data', 'poolException', 'workerException');
         if (is_array($result) && count($resultTypes = array_intersect(array_keys($result), $possibleArrayKeys)) === 1) {
             // If the result has the expected format, free the worker and store the result.
             // Otherwise, the worker may be abnormally terminated (fatal error, exit(), ...) and will
             // fall in the reapers arms.
             $this->workerProcesses->registerFreeProcessId($processId);
             $result['pid'] = $processId;
             $resultType = reset($resultTypes);
             // Do not store NULL
             if ($resultType !== 'data' || $result['data'] !== NULL) {
                 array_push($this->results, $result);
             }
         }
     }
     // dispatch signals
     pcntl_signal_dispatch();
 }
开发者ID:sajib-hassan,项目名称:WorkerPool,代码行数:34,代码来源:WorkerPool.php


示例10: fetch

 /**
  *    Fetches the content and parses the headers.
  *    @param $socket        Test override.
  *    @return               Either false or a HttpResponse.
  *    @access public
  */
 function fetch($socket = false)
 {
     if (!is_object($socket)) {
         $socket = new SimpleSocket($this->_url->getHost());
     }
     if ($socket->isError()) {
         return false;
     }
     $socket->write("GET " . $this->_url->getPath() . $this->_url->getEncodedRequest() . " HTTP/1.0\r\n");
     $socket->write("Host: " . $this->_url->getHost() . "\r\n");
     foreach ($this->_user_headers as $header_line) {
         $socket->write($header_line . "\r\n");
     }
     if (count($this->_cookies) > 0) {
         $socket->write("Cookie: " . $this->_marshallCookies($this->_cookies) . "\r\n");
     }
     $socket->write("Connection: close\r\n");
     $socket->write("\r\n");
     return $this->_createResponse($socket);
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:26,代码来源:http.php


示例11: while

 /**
  *    Reads the whole of the socket output into a
  *    single string.
  *    @param SimpleSocket $socket  Unread socket.
  *    @return string               Raw output if successful
  *                                 else false.
  *    @access private
  */
 function _readAll(&$socket) {
     $all = "";
     while ($next = $socket->read()) {
         $all .= $next;
     }
     return $all;
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:15,代码来源:http.php


示例12: skip

 function skip()
 {
     $socket = new SimpleSocket($this->host, $this->port, 5, 8);
     parent::skipIf(!$socket->isOpen(), sprintf('The LiveHttpTestCase requires that a webserver runs at %s:%s', $this->host, $this->port));
 }
开发者ID:simpletest,项目名称:simpletest,代码行数:5,代码来源:acceptance_test.php


示例13: run

 /**
  *    Runs the test methods in the test case, or not if the
  *    scorer blocks it.
  *    @param SimpleTest $test_case    Test case to run test on.
  *    @param string $method           Name of test method.
  *    @access public
  */
 function run()
 {
     $methods = get_class_methods(get_class($this->_test_case));
     $invoker =& $this->_test_case->createInvoker();
     foreach ($methods as $method) {
         if (!$this->_isTest($method)) {
             continue;
         }
         if ($this->_isConstructor($method)) {
             continue;
         }
         ob_start();
         echo $this->_start;
         $this->_scorer->paintMethodStart($method);
         if ($this->_scorer->shouldInvoke($this->_test_case->getLabel(), $method)) {
             $invoker->invoke($method);
         }
         $this->_scorer->paintMethodEnd($method);
         echo $this->_end;
         $output = ob_get_contents();
         ob_end_clean();
         $sock = new SimpleSocket("127.0.0.1", $this->_port, 5);
         $sock->write($output);
         $sock->close();
         echo $sock->getError();
     }
 }
开发者ID:sebs,项目名称:simpletest,代码行数:34,代码来源:eclipsetest.php


示例14:

 /**
  *    Actually opens the low level socket.
  *    @param string $host          Host to connect to.
  *    @param integer $port         Port on host.
  *    @param integer $error_number Recipient of error code.
  *    @param string $error         Recipient of error message.
  *    @param integer $timeout      Maximum time to wait for connection.
  *    @access protected
  */
 function _openSocket($host, $port, &$error_number, &$error, $timeout)
 {
     return parent::_openSocket("tls://{$host}", $port, $error_number, $error, $timeout);
 }
开发者ID:ljarray,项目名称:dbpedia,代码行数:13,代码来源:socket.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP SimpleStackTrace类代码示例发布时间:2022-05-23
下一篇:
PHP SimpleSAML_XHTML_Template类代码示例发布时间: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