急!!请问php中是否可以接收来自c程序往消息队列中放的消息 因为php支持消息队列,有往消息队列中收发消息的函数.但是我用c写的往同一个队列中放消息,为和php从消息队列中收不到呢,总说msg_receive(): message corrupted 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以的.检查你的 c 与 php 的操作 message queue 参数是否一致. 这是c程序#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 2048struct 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);} 这是php程序,请大家帮忙看看,为何php收不到来自c发送的消息队列的消息<? $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; }?> function下面的foreach返回怎么只返回一条信息? php 时间问题,大虾请进 [讨论+散分]我自己写的东西,用来求职.....大家给点建议 php读取二进制文件流乱码,有答案就结贴 怎么传递头部,帮帮小妹,第2次问这个问题了 SmartTemplate解析模版时的语言包分离问题 新手请教session问题! 关于网页过期的问题 不能重新定位url,急啊!!! 大侠帮忙!!!我的IIS起不了了!!! 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;
}?>