激情久久久_欧美视频区_成人av免费_不卡视频一二三区_欧美精品在欧美一区二区少妇_欧美一区二区三区的

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術(shù)|正則表達(dá)式|C/C++|IOS|C#|Swift|Android|VB|R語(yǔ)言|JavaScript|易語(yǔ)言|vb.net|

服務(wù)器之家 - 編程語(yǔ)言 - PHP教程 - PHP的消息通信機(jī)制測(cè)試實(shí)例

PHP的消息通信機(jī)制測(cè)試實(shí)例

2021-03-22 18:19flandycheng PHP教程

這篇文章主要介紹了PHP的消息通信機(jī)制,結(jié)合實(shí)例形式分析了php消息通信的信息發(fā)送與獲取相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了PHP的消息通信機(jī)制。分享給大家供大家參考,具體如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php error_reporting(E_ALL&~E_WARNING&~E_NOTICE);
/**
 * Example for sending and receiving Messages via the System V Message Queue
 *
 * To try this script run it synchron/asynchron twice times. One time with ?type=send and one time with ?type=receive
 *
 * @author     Thomas Eimers - Mehrkanal GmbH
 *
 * This document is distributed in the hope that it will be useful, but without any warranty;
 * without even the implied warranty of merchantability or fitness for a particular purpose.
 */
ob_implicit_flush(1);
header('Content-Type: text/plain; charset=ISO-8859-1');
echo "Start...\n";
// Create System V Message Queue. Integer value is the number of the Queue
//$queue = msg_get_queue(100379);
$mesg_key = ftok(__FILE__, 'm');
$mesg_id = msg_get_queue($mesg_key, 0666);
$queue = $mesg_id;
// Sendoptions
$serialize_needed=false; // Must the transfer data be serialized ?
$block_send=false;    // Block if Message could not be send (Queue full...) (true/false)
$msgtype_send=1;     // Any Integer above 0. It signeds every Message. So you could handle multible message
             // type in one Queue.
// Receiveoptions
$msgtype_receive=1;    // Whiche type of Message we want to receive ? (Here, the type is the same as the type we send,
             // but if you set this to 0 you receive the next Message in the Queue with any type.
$maxsize=100;       // How long is the maximal data you like to receive.
$option_receive=MSG_IPC_NOWAIT; // If there are no messages of the wanted type in the Queue continue without wating.
             // If is set to NULL wait for a Message.
// Send or receive 20 Messages
for ($i=0;$i<20;$i++) {
   sleep(1);
  ob_flush();
  flush();
 $message='Hello, This is Flandy,now is '.date("H:i:s",time());   // Transfering Data
 // This one sends
  if (isset($_GET['type'])&&$_GET['type']=='send') {
  if(msg_send($queue,$msgtype_send, $message,$serialize_needed, $block_send,$err)===true) {
   echo "The ".$i." Message has been sent, the messge is ".$message."\n";
  } else {
   var_dump($err);
  }
 // This one received
 } else {
   $queue_status=msg_stat_queue($queue);
   echo 'Get Messages in the queue: '.$queue_status['msg_qnum']."\n";
   print_r($queue_status);
   echo "\n";
  if ($queue_status['msg_qnum']>0) {
   if (msg_receive($queue,$msgtype_receive ,$msgtype_erhalten,$maxsize,$daten,$serialize_needed, $option_receive, $err)===true) {
       echo "Received data:".$daten."\n";
   } else {
       var_dump($err);
   }
  }
 }
}
?>

希望本文所述對(duì)大家PHP程序設(shè)計(jì)有所幫助。

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 欧美一级在线免费 | 欧美成人精品欧美一级乱黄 | 鲁久久 | 国产精品美女一区二区 | 国产精品视频成人 | 色播av在线 | 黄色免费小视频网站 | 欧美成人精品一区二区 | 久久久国产精品免费观看 | 亚洲av毛片久久久久 | 国产毛片毛片 | 久久久久国产视频 | 国产1区2区3区中文字幕 | 国产精品久久久久久久久久10秀 | 少妇色诱麻豆色哟哟 | 久久久久国产成人免费精品免费 | 日本欧美视频 | 视频一区二区中文字幕 | 麻豆porn | 欧美成人午夜影院 | 在线观看免费毛片视频 | 高清成人在线 | 日韩av片网站 | av在线影片 | 午夜亚洲影院 | 精品人伦一区二区三区蜜桃网站 | 日本网站一区二区三区 | 毛片免| 成人免费久久网 | a一级黄| 婷婷一区二区三区 | 性欧美videos另类极品 | 国产日产精品一区二区三区四区 | 特级a欧美做爰片毛片 | 狠狠干狠狠操 | 日日夜av| 奇米888一区二区三区 | 色视频在线播放 | 天堂成人国产精品一区 | 欧产日产国产精品乱噜噜 | 国产精品性夜天天视频 |