因为php支持消息队列,有往消息队列中收发消息的函数.但是我用c写的往同一个队列中放消息,为和php从消息队列中收不到呢,总说msg_receive(): message corrupted
解决方案 »
- 一个正则问题
- 这句php运行怎么出错了?
- php中\n产生的换行问题
- 试用 edong.com 的空间所遇到的问题。我上传了个探针,大家帮我看看。
- 帮帮忙, 怎样用pear DB连数据库,看看我的最简单代码
- 求助!网页的源文件中有许多空格,有什么软件可以一次性去掉这些空格!急!
- 500分求答不是难题的难题!
- 急!!我用PHP往一个Access数据库中添加记录,为什么总提示我错误呢?(UP有分)
- 很多论坛为防止用户上传 javascript 语句,在用户提交文本时把“<”转换为“<”请问有什么办法能提交“<"吗?
- 怎样通过web修改用户的密码?
- PHP提供的MYSQL数据集函数不能像ASP的SELECT结果集一样直接更新?
- 求助一个PHP的数组问题(我想应该比较simple,但是我没有弄出来)
检查你的 c 与 php 的操作 message queue 参数是否一致.
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include<stdio.h>
//#include<stdlib.h>
//#include<linux/ipc.h>
//#include<linux/msg.h>
#define BUFFER 2048
struct msgtype
{
int mtype;
//char * buffer;
char buffer[BUFFER+1];
};
main()
{
int qid,sflags;
int MSGKEY = 2345; int result,length;
struct msgtype msg;
int i = 1; qid=msgget(MSGKEY,0600);
printf("the key of msg is %d",qid);
msg.mtype=1001;
msg.buffer[0]='a';
msgsnd(qid,&msg,sizeof(msg),sflags);
}
<?
$MSGKEY = 2345;
$msg_id = msg_get_queue($MSGKEY, 0600);
echo $msg_id;
// $MSGREV = 2346;
// $msgrev_id = msg_get_queue($MSGREV,0600);
$xml="nihao";
// if (!msg_send($msg_id,1001,$xml, true, true, $msg_err))
// echo "Msg not sent because $msg_err\n"; // echo strlen($xml);
// for($i=0;$i<100;)
//{
// echo"hello";
// $i++;
//}
$sflag=MSG_IPC_NOWAIT; if((msg_receive ($msg_id,0,$msg_type,18566,$msg,true,$sflag,
$msg_error))==FALSE)
{
echo $msg_type;
echo "failed,$msg_error";
$errormsg= posix_strerror($msg_error);
echo $errormsg;
echo $msg;
}
else
{
echo $msg;
}?>