转载于:http://blog.csdn.net/yao970953039/article/details/41821387

1.系统centos 我是直接使用yum install beanstalk安装的

2.下载beanstalk的php扩展包 放在extensions

  1. //控制器往队列里面塞任务  @author yao
  2. Yii::import('application.extensions.SendSmsBeanstalk');
  3. class AController extends CController{
  4. public function actionIndex(){
  5. for($i=0;$i<1000;$i++){
  6. SendSmsBeanstalk::sendSms('sendsms_'.$i);
  7. }
  8. }
  9. public function actionA(){
  10. SendSmsBeanstalk::handleMessage();
  11. }
  12. }
  1. </pre><pre code_snippet_id="546591" snippet_file_name="blog_20141209_4_7698245" name="code" class="php">//发送短信  @author yao
  2. Yii::import('application.extensions.beanstalk.*');
  3. class SendSmsBeanstalk extends CComponent{
  4. //建立发短信任务
  5. public static function sendSms($body){
  6. //实例化beanstalk
  7. $beanstalk = new Socket_Beanstalk();
  8. if (!$beanstalk->connect()) {
  9. exit(current($beanstalk->errors()));
  10. }
  11. //选择使用的tube
  12. $beanstalk->useTube('hube_send_smss');
  13. //往tube中增加数据
  14. $put = $beanstalk->put(
  15. 23, // 任务的优先级.
  16. 0, // 不等待直接放到ready队列中.
  17. 60, // 处理任务的时间.
  18. $body // 任务内容
  19. );
  20. if (!$put) {
  21. return false;
  22. }
  23. $beanstalk->disconnect();
  24. }
  25. //处理消息
  26. public static function handleMessage(){
  27. //实例化beanstalk
  28. $beanstalk = new Socket_Beanstalk();
  29. if (!$beanstalk->connect()) {
  30. exit(current($beanstalk->errors()));
  31. }
  32. $beanstalk->useTube('hube_send_smss');
  33. //设置要监听的tube
  34. $beanstalk->watch('hube_send_smss');
  35. //取消对默认tube的监听,可以省略
  36. $beanstalk->ignore('default');
  37. while($job = $beanstalk->reserve(2)){//这里我写了单个任务只执行2秒。防止超时。本地测试的时候 没写超时会一直执行下去,哪怕队列里面已经没有任务
  38. //处理任务
  39. $result = $job['body'];
  40. echo $job['id'];echo '<br>';//打印任务ID
  41. if ($result) {<span style="font-family: Arial, Helvetica, sans-serif;">//这里可以写逻辑 todo</span>
  1. //删除任务
  2. $beanstalk->delete($job['id']);
  3. } else {
  4. //休眠任务
  5. $beanstalk->bury($job['id'],'');
  6. }
  7. }
  8. $beanstalk->disconnect();
  9. }

下方提供我找到的队列PHP版本core,不能上传附件。代码在下面

  1. /**
  2. * beanstalk: A minimalistic PHP beanstalk client.
  3. *
  4. * Copyright (c) 2009-2012 David Persson
  5. *
  6. * Distributed under the terms of the MIT License.
  7. * Redistributions of files must retain the above copyright notice.
  8. *
  9. * @copyright  2009-2012 David Persson <nperson@gmx.de>
  10. * @license    http://www.opensource.org/licenses/mit-license.php The MIT License
  11. * @link       http://github.com/davidpersson/beanstalk
  12. */
  13. /**
  14. * An interface to the beanstalk queue service. Implements the beanstalk
  15. * protocol spec 1.2. Where appropriate the documentation from the protcol has
  16. * been added to the docblocks in this class.
  17. *
  18. * @link https://github.com/kr/beanstalkd/blob/master/doc/protocol.txt
  19. */
  20. class Socket_Beanstalk {
  21. /**
  22. * Holds a boolean indicating whether a connection to the server is
  23. * currently established or not.
  24. *
  25. * @var boolean
  26. */
  27. public $connected = false;
  28. /**
  29. * Holds configuration values.
  30. *
  31. * @var array
  32. */
  33. protected $_config = array();
  34. /**
  35. * The current connection resource handle (if any).
  36. *
  37. * @var resource
  38. */
  39. protected $_connection;
  40. /**
  41. * Generated errors. Will hold a maximum of 200 error messages at any time
  42. * to prevent pilling up messages and using more and more memory. This is
  43. * especially important if this class is used in long-running workers.
  44. *
  45. * @see Socket_Beanstalk::errors()
  46. * @see Socket_Beanstalk::_error()
  47. * @var array
  48. */
  49. protected $_errors = array();
  50. /**
  51. * Constructor.
  52. *
  53. * @param array $config An array of configuration values:
  54. *        - `'persistent'`  Whether to make the connection persistent or
  55. *                          not, defaults to `true` as the FAQ recommends
  56. *                          persistent connections.
  57. *        - `'host'`        The beanstalk server hostname or IP address to
  58. *                          connect to, defaults to `127.0.0.1`.
  59. *        - `'port'`        The port of the server to connect to, defaults
  60. *                          to `11300`.
  61. *        - `'timeout'`     Timeout in seconds when establishing the
  62. *                          connection, defaults to `1`.
  63. * @return void
  64. */
  65. public function __construct(array $config = array()) {
  66. $defaults = array(
  67. 'persistent' => true,
  68. 'host' => '127.0.0.1',
  69. 'port' => 11300,
  70. 'timeout' => 1
  71. );
  72. $this->_config = $config + $defaults;
  73. }
  74. /**
  75. * Destructor, disconnects from the server.
  76. *
  77. * @return void
  78. */
  79. public function __destruct() {
  80. $this->disconnect();
  81. }
  82. /**
  83. * Initiates a socket connection to the beanstalk server. The resulting
  84. * stream will not have any timeout set on it. Which means it can wait an
  85. * unlimited amount of time until a packet becomes available. This is
  86. * required for doing blocking reads.
  87. *
  88. * @see Socket_Beanstalk::$_connection
  89. * @see Socket_Beanstalk::reserve()
  90. * @return boolean `true` if the connection was established, `false` otherwise.
  91. */
  92. public function connect() {
  93. if (isset($this->_connection)) {
  94. $this->disconnect();
  95. }
  96. $function = $this->_config['persistent'] ? 'pfsockopen' : 'fsockopen';
  97. $params = array($this->_config['host'], $this->_config['port'], &$errNum, &$errStr);
  98. if ($this->_config['timeout']) {
  99. $params[] = $this->_config['timeout'];
  100. }
  101. $this->_connection = @call_user_func_array($function, $params);
  102. if (!empty($errNum) || !empty($errStr)) {
  103. $this->_error("{$errNum}: {$errStr}");
  104. }
  105. $this->connected = is_resource($this->_connection);
  106. if ($this->connected) {
  107. stream_set_timeout($this->_connection, -1);
  108. }
  109. return $this->connected;
  110. }
  111. /**
  112. * Closes the connection to the beanstalk server.
  113. *
  114. * @return boolean `true` if diconnecting was successful.
  115. */
  116. public function disconnect() {
  117. if (!is_resource($this->_connection)) {
  118. $this->connected = false;
  119. } else {
  120. $this->connected = !fclose($this->_connection);
  121. if (!$this->connected) {
  122. $this->_connection = null;
  123. }
  124. }
  125. return !$this->connected;
  126. }
  127. /**
  128. * Returns collected error messages.
  129. *
  130. * @return array An array of error messages.
  131. */
  132. public function errors() {
  133. return $this->_errors;
  134. }
  135. /**
  136. * Pushes an error message to `Beanstalk::$_errors`. Ensures
  137. * that at any point there are not more than 200 messages.
  138. *
  139. * @param string $message The error message.
  140. * @return void
  141. */
  142. protected function _error($message) {
  143. if (count($this->_errors) >= 200) {
  144. array_shift($this->_errors);
  145. }
  146. array_push($this->_errors, $message);
  147. }
  148. /**
  149. * Writes a packet to the socket. Prior to writing to the socket will check
  150. * for availability of the connection.
  151. *
  152. * @param string $data
  153. * @return integer|boolean number of written bytes or `false` on error.
  154. */
  155. protected function _write($data) {
  156. if (!$this->connected && !$this->connect()) {
  157. return false;
  158. }
  159. $data .= "\r\n";
  160. return fwrite($this->_connection, $data, strlen($data));
  161. }
  162. /**
  163. * Reads a packet from the socket. Prior to reading from the socket will
  164. * check for availability of the connection.
  165. *
  166. * @param int $length Number of bytes to read.
  167. * @return string|boolean Data or `false` on error.
  168. */
  169. protected function _read($length = null) {
  170. if (!$this->connected && !$this->connect()) {
  171. return false;
  172. }
  173. if ($length) {
  174. if (feof($this->_connection)) {
  175. return false;
  176. }
  177. $data = fread($this->_connection, $length + 2);
  178. $meta = stream_get_meta_data($this->_connection);
  179. if ($meta['timed_out']) {
  180. $this->_error('Connection timed out.');
  181. return false;
  182. }
  183. $packet = rtrim($data, "\r\n");
  184. } else {
  185. $packet = stream_get_line($this->_connection, 16384, "\r\n");
  186. }
  187. return $packet;
  188. }
  189. /* Producer Commands */
  190. /**
  191. * The `put` command is for any process that wants to insert a job into the queue.
  192. *
  193. * @param integer $pri Jobs with smaller priority values will be scheduled
  194. *        before jobs with larger priorities. The most urgent priority is
  195. *        0; the least urgent priority is 4294967295.
  196. * @param integer $delay Seconds to wait before putting the job in the
  197. *        ready queue.  The job will be in the "delayed" state during this time.
  198. * @param integer $ttr Time to run - Number of seconds to allow a worker to
  199. *        run this job.  The minimum ttr is 1.
  200. * @param string $data The job body.
  201. * @return integer|boolean `false` on error otherwise an integer indicating
  202. *         the job id.
  203. */
  204. public function put($pri, $delay, $ttr, $data) {
  205. $this->_write(sprintf('put %d %d %d %d', $pri, $delay, $ttr, strlen($data)));
  206. $this->_write($data);
  207. $status = strtok($this->_read(), ' ');
  208. switch ($status) {
  209. case 'INSERTED':
  210. case 'BURIED':
  211. return (integer)strtok(' '); // job id
  212. case 'EXPECTED_CRLF':
  213. case 'JOB_TOO_BIG':
  214. default:
  215. $this->_error($status);
  216. return false;
  217. }
  218. }
  219. /**
  220. * The `use` command is for producers. Subsequent put commands will put jobs into
  221. * the tube specified by this command. If no use command has been issued, jobs
  222. * will be put into the tube named `default`.
  223. *
  224. * Please note that while obviously this method should better be named
  225. * `use` it is not. This is because `use` is a reserved keyword in PHP.
  226. *
  227. * @param string $tube A name at most 200 bytes. It specifies the tube to
  228. *        use.  If the tube does not exist, it will be created.
  229. * @return string|boolean `false` on error otherwise the name of the tube.
  230. */
  231. public function choose($tube) {
  232. $this->_write(sprintf('use %s', $tube));
  233. $status = strtok($this->_read(), ' ');
  234. switch ($status) {
  235. case 'USING':
  236. return strtok(' ');
  237. default:
  238. $this->_error($status);
  239. return false;
  240. }
  241. }
  242. /**
  243. * Alias for choose.
  244. *
  245. * @see Socket_Beanstalk::choose()
  246. * @param string $tube
  247. * @return string|boolean
  248. */
  249. public function useTube($tube) {
  250. return $this->choose($tube);
  251. }
  252. /* Worker Commands */
  253. /**
  254. * Reserve a job (with a timeout)
  255. *
  256. * @param integer $timeout If given specifies number of seconds to wait for
  257. *        a job. 0 returns immediately.
  258. * @return array|false `false` on error otherwise an array holding job id
  259. *         and body.
  260. */
  261. public function reserve($timeout = null) {
  262. if (isset($timeout)) {
  263. $this->_write(sprintf('reserve-with-timeout %d', $timeout));
  264. } else {
  265. $this->_write('reserve');
  266. }
  267. $status = strtok($this->_read(), ' ');
  268. switch ($status) {
  269. case 'RESERVED':
  270. return array(
  271. 'id' => (integer)strtok(' '),
  272. 'body' => $this->_read((integer)strtok(' '))
  273. );
  274. case 'DEADLINE_SOON':
  275. case 'TIMED_OUT':
  276. default:
  277. $this->_error($status);
  278. return false;
  279. }
  280. }
  281. /**
  282. * Removes a job from the server entirely.
  283. *
  284. * @param integer $id The id of the job.
  285. * @return boolean `false` on error, `true` on success.
  286. */
  287. public function delete($id) {
  288. $this->_write(sprintf('delete %d', $id));
  289. $status = $this->_read();
  290. switch ($status) {
  291. case 'DELETED':
  292. return true;
  293. case 'NOT_FOUND':
  294. default:
  295. $this->_error($status);
  296. return false;
  297. }
  298. }
  299. /**
  300. * Puts a reserved job back into the ready queue.
  301. *
  302. * @param integer $id The id of the job.
  303. * @param integer $pri Priority to assign to the job.
  304. * @param integer $delay Number of seconds to wait before putting the job in the ready queue.
  305. * @return boolean `false` on error, `true` on success.
  306. */
  307. public function release($id, $pri, $delay) {
  308. $this->_write(sprintf('release %d %d %d', $id, $pri, $delay));
  309. $status = $this->_read();
  310. switch ($status) {
  311. case 'RELEASED':
  312. case 'BURIED':
  313. return true;
  314. case 'NOT_FOUND':
  315. default:
  316. $this->_error($status);
  317. return false;
  318. }
  319. }
  320. /**
  321. * Puts a job into the `buried` state Buried jobs are put into a FIFO
  322. * linked list and will not be touched until a client kicks them.
  323. *
  324. * @param integer $id The id of the job.
  325. * @param integer $pri *New* priority to assign to the job.
  326. * @return boolean `false` on error, `true` on success.
  327. */
  328. public function bury($id, $pri) {
  329. $this->_write(sprintf('bury %d %d', $id, $pri));
  330. $status = $this->_read();
  331. switch ($status) {
  332. case 'BURIED':
  333. return true;
  334. case 'NOT_FOUND':
  335. default:
  336. $this->_error($status);
  337. return false;
  338. }
  339. }
  340. /**
  341. * Allows a worker to request more time to work on a job
  342. *
  343. * @param integer $id The id of the job.
  344. * @return boolean `false` on error, `true` on success.
  345. */
  346. public function touch($id) {
  347. $this->_write(sprintf('touch %d', $id));
  348. $status = $this->_read();
  349. switch ($status) {
  350. case 'TOUCHED':
  351. return true;
  352. case 'NOT_TOUCHED':
  353. default:
  354. $this->_error($status);
  355. return false;
  356. }
  357. }
  358. /**
  359. * Adds the named tube to the watch list for the current
  360. * connection.
  361. *
  362. * @param string $tube Name of tube to watch.
  363. * @return integer|boolean `false` on error otherwise number of tubes in watch list.
  364. */
  365. public function watch($tube) {
  366. $this->_write(sprintf('watch %s', $tube));
  367. $status = strtok($this->_read(), ' ');
  368. switch ($status) {
  369. case 'WATCHING':
  370. return (integer)strtok(' ');
  371. default:
  372. $this->_error($status);
  373. return false;
  374. }
  375. }
  376. /**
  377. * Remove the named tube from the watch list.
  378. *
  379. * @param string $tube Name of tube to ignore.
  380. * @return integer|boolean `false` on error otherwise number of tubes in watch list.
  381. */
  382. public function ignore($tube) {
  383. $this->_write(sprintf('ignore %s', $tube));
  384. $status = strtok($this->_read(), ' ');
  385. switch ($status) {
  386. case 'WATCHING':
  387. return (integer)strtok(' ');
  388. case 'NOT_IGNORED':
  389. default:
  390. $this->_error($status);
  391. return false;
  392. }
  393. }
  394. /* Other Commands */
  395. /**
  396. * Inspect a job by its id.
  397. *
  398. * @param integer $id The id of the job.
  399. * @return string|boolean `false` on error otherwise the body of the job.
  400. */
  401. public function peek($id) {
  402. $this->_write(sprintf('peek %d', $id));
  403. return $this->_peekRead();
  404. }
  405. /**
  406. * Inspect the next ready job.
  407. *
  408. * @return string|boolean `false` on error otherwise the body of the job.
  409. */
  410. public function peekReady() {
  411. $this->_write('peek-ready');
  412. return $this->_peekRead();
  413. }
  414. /**
  415. * Inspect the job with the shortest delay left.
  416. *
  417. * @return string|boolean `false` on error otherwise the body of the job.
  418. */
  419. public function peekDelayed() {
  420. $this->_write('peek-delayed');
  421. return $this->_peekRead();
  422. }
  423. /**
  424. * Inspect the next job in the list of buried jobs.
  425. *
  426. * @return string|boolean `false` on error otherwise the body of the job.
  427. */
  428. public function peekBuried() {
  429. $this->_write('peek-buried');
  430. return $this->_peekRead();
  431. }
  432. /**
  433. * Handles response for all peek methods.
  434. *
  435. * @return string|boolean `false` on error otherwise the body of the job.
  436. */
  437. protected function _peekRead() {
  438. $status = strtok($this->_read(), ' ');
  439. switch ($status) {
  440. case 'FOUND':
  441. return array(
  442. 'id' => (integer)strtok(' '),
  443. 'body' => $this->_read((integer)strtok(' '))
  444. );
  445. case 'NOT_FOUND':
  446. default:
  447. $this->_error($status);
  448. return false;
  449. }
  450. }
  451. /**
  452. * Moves jobs into the ready queue (applies to the current tube).
  453. *
  454. * If there are buried jobs those get kicked only otherwise
  455. * delayed jobs get kicked.
  456. *
  457. * @param integer $bound Upper bound on the number of jobs to kick.
  458. * @return integer|boolean False on error otherwise number of job kicked.
  459. */
  460. public function kick($bound) {
  461. $this->_write(sprintf('kick %d', $bound));
  462. $status = strtok($this->_read(), ' ');
  463. switch ($status) {
  464. case 'KICKED':
  465. return (integer)strtok(' ');
  466. default:
  467. $this->_error($status);
  468. return false;
  469. }
  470. }
  471. /* Stats Commands */
  472. /**
  473. * Gives statistical information about the specified job if it exists.
  474. *
  475. * @param integer $id The job id
  476. * @return string|boolean `false` on error otherwise a string with a yaml formatted dictionary
  477. */
  478. public function statsJob($id) {
  479. $this->_write(sprintf('stats-job %d', $id));
  480. return $this->_statsRead();
  481. }
  482. /**
  483. * Gives statistical information about the specified tube if it exists.
  484. *
  485. * @param string $tube Name of the tube.
  486. * @return string|boolean `false` on error otherwise a string with a yaml formatted dictionary.
  487. */
  488. public function statsTube($tube) {
  489. $this->_write(sprintf('stats-tube %s', $tube));
  490. return $this->_statsRead();
  491. }
  492. /**
  493. * Gives statistical information about the system as a whole.
  494. *
  495. * @return string|boolean `false` on error otherwise a string with a yaml formatted dictionary.
  496. */
  497. public function stats() {
  498. $this->_write('stats');
  499. return $this->_statsRead();
  500. }
  501. /**
  502. * Returns a list of all existing tubes.
  503. *
  504. * @return string|boolean `false` on error otherwise a string with a yaml formatted list.
  505. */
  506. public function listTubes() {
  507. $this->_write('list-tubes');
  508. return $this->_statsRead();
  509. }
  510. /**
  511. * Returns the tube currently being used by the producer.
  512. *
  513. * @return string|boolean `false` on error otherwise a string with the name of the tube.
  514. */
  515. public function listTubeUsed() {
  516. $this->_write('list-tube-used');
  517. $status = strtok($this->_read(), ' ');
  518. switch ($status) {
  519. case 'USING':
  520. return strtok(' ');
  521. default:
  522. $this->_error($status);
  523. return false;
  524. }
  525. }
  526. /**
  527. * Alias for listTubeUsed.
  528. *
  529. * @see Socket_Beanstalk::listTubeUsed()
  530. * @return string|boolean `false` on error otherwise a string with the name of the tube.
  531. */
  532. public function listTubeChosen() {
  533. return $this->listTubeUsed();
  534. }
  535. /**
  536. * Returns a list of tubes currently being watched by the worker.
  537. *
  538. * @return string|boolean `false` on error otherwise a string with a yaml formatted list.
  539. */
  540. public function listTubesWatched() {
  541. $this->_write('list-tubes-watched');
  542. return $this->_statsRead();
  543. }
  544. /**
  545. * Handles responses for all stat methods.
  546. *
  547. * @param boolean $decode Whether to decode data before returning it or not. Default is `true`.
  548. * @return array|string|boolean `false` on error otherwise statistical data.
  549. */
  550. protected function _statsRead($decode = true) {
  551. $status = strtok($this->_read(), ' ');
  552. switch ($status) {
  553. case 'OK':
  554. $data = $this->_read((integer)strtok(' '));
  555. return $decode ? $this->_decode($data) : $data;
  556. default:
  557. $this->_error($status);
  558. return false;
  559. }
  560. }
  561. /**
  562. * Decodes YAML data. This is a super naive decoder which just works on a
  563. * subset of YAML which is commonly returned by beanstalk.
  564. *
  565. * @param string $data The data in YAML format, can be either a list or a dictionary.
  566. * @return array An (associative) array of the converted data.
  567. */
  568. protected function _decode($data) {
  569. $data = array_slice(explode("\n", $data), 1);
  570. $result = array();
  571. foreach ($data as $key => $value) {
  572. if ($value[0] === '-') {
  573. $value = ltrim($value, '- ');
  574. } elseif (strpos($value, ':') !== false) {
  575. list($key, $value) = explode(':', $value);
  576. $value = ltrim($value, ' ');
  577. }
  578. if (is_numeric($value)) {
  579. $value = (integer) $value == $value ? (integer) $value : (float) $value;
  580. }
  581. $result[$key] = $value;
  582. }
  583. return $result;
  584. }
  585. }

安装成功是上面这样子

YII使用beanstalk队列的更多相关文章

  1. Yii2 使用 Beanstalk 队列系统

    参考网址: Beanstalk:https://github.com/kr/beanstalkd Beanstalk console:https://github.com/ptrofimov/bean ...

  2. YII相关资料(干货)

    Sites 网站 yiifeed:Yii 最新动态都在这里 yiigist:Yii 专用的 Packages my-yii:Yii 学习资料和新闻 Docs 文档 Yii Framework 2.0 ...

  3. yii2干货

    Sites 网站 yiifeed:Yii 最新动态都在这里 yiigist:Yii 专用的 Packages my-yii:Yii 学习资料和新闻 Docs 文档 Yii Framework 2.0 ...

  4. yii2.0 干货

    Yii2 干货集,欢迎提交 Pull Requests.(提交过来的开源项目最好是你用过的,并且觉得好用的) Docs 文档 Yii Framework 2.0 类参考手册 Yii Framework ...

  5. Beanstalk消息队列的实现

    在工作中要用到消息队列,但是主管为了追求开发速度,让用了一个简易的类  beanstalk 下面来说明这个东西 参考博客:https://my.oschina.net/u/698121/blog/15 ...

  6. 一个高性能、轻量级的分布式内存队列系统--beanstalk

    Beanstalk是一个高性能.轻量级的.分布式的.内存型的消息队列系统.最初设计的目的是想通过后台异步执行耗时的任务来降低高容量Web应用系统的页面访问延迟.其实Beanstalkd是典型的类Mem ...

  7. php 使用beanstalk 消息队列

    Beanstalkd 消息队列 一.基本信息Beanstalkd,一个高性能.轻量级的分布式内存队列系统,最初设计的目的是想通过后台异步执行耗时的任务来降低高容量Web应用系统的页面访问延迟,支持过有 ...

  8. PHP消息队列之Beanstalk

    Beanstalk,一个高性能.轻量级的分布式内存队列

  9. 【消息队列值Beanstalk】beeanstalk初识

    Beanstalk是一个高性能.轻量级的.分布式的.内存型的消息队列系统.最初设计的目的是想通过后台异步执行耗时的任务来降低高容量Web应用系统的页面访问延迟.其实Beanstalkd是典型的类Mem ...

随机推荐

  1. elasticsearch索引目录设置

    path.data and path.logs If you are using the .zip or .tar.gz archives, the data and logs directories ...

  2. Linux必备命令

      目录                                                              概述 常用系统工作命令 系统状态检测命令 工作目录切换命令 文本文件 ...

  3. POJ 1087

    #include<iostream> #include<stdio.h> #include<string> #define MAXN 105 using names ...

  4. JavaScript中的垃圾回收机制与内存泄露

    什么是内存泄露? 任何编程语言,在运行时都需要使用到内存,比如在一个函数中, var arr = [1, 2, 3, 4, 5]; 这么一个数组,就需要内存. 但是,在使用了这些内存之后, 如果后面他 ...

  5. MAC帧格式、IPV4数据报格式、TCP报文格式、UDP数据报格式

    1.MAC帧格式 类型:2字节,指出数据域中携带的数据应交给哪些协议实体处理 校验码:校验数据段(采用32位CRC冗余校验方式进行校验) 2.IPV4数据报 版本:IP协议版本,这里为4 首部长度:占 ...

  6. springboot打包成jar包后找不到xml,找不到主类的解决方法

    springboot打包成jar包后找不到xml,找不到主类的解决方法 请首先保证你的项目能正常运行(即不打包的时候运行无误),我们在打包时经常遇到如下问题: springboot打包成jar包后找不 ...

  7. android的几种“通知”方式简单实现(Notification&NotificationManager)

    关于通知Notification相信大家都不陌生了,平时上QQ的时候有消息来了或者有收到了短信,手机顶部就会显示有新消息什么的,就类似这种.今天就稍微记录下几种Notification的用法.3.0以 ...

  8. Javac之glb与lub

    5.1.10. Capture Conversion Let G name a generic type declaration (§8.1.2, §9.1.2) with n type parame ...

  9. Chapter 3 Phenomenon——5

    I saw several things simultaneously. 我同时看见了几件事情. Nothing was moving in slow motion,the way it does i ...

  10. linux ping 命令解析

    不管在windows平台,还是在linux平台,ping都是非常常用的网络命令:ping命令通过ICMP(Internet控制消息协议)工作:ping可以用来测试本机与目标主机是否联通.联通速度如何. ...