请大家讨论一下消息队列的用处,及消息队列要掌握的知识??????????????:em02:
by kellenforever - C/C++ - 2010-04-28 08:35:07 阅读(1461) 回复(5)
/*Server.c*/ #include #include #include #include #include #include #include #include #include #define MSG_FILE "server.c" #define BUFFER 255 #define PERM S_IWUSR|S_IRUSR struct msgtype { long mtype; char buffer[BUFFER+1]; }; int main() { struct msgtype msg; key_t key; int msgid; /*create key filetokey*/ if((key=ftok(MSG_FILE,'a'))==-1) { fprintf(stderr,"Create key error:%s\a\n",strerror(...
#include "unp.h" #define PERM (S_IRUSR | S_IWUSR) struct msgbuf { /* message structure */ long mtype; char mtext[1]; }; int main(void) { int msgid; pid_t pid; if ((msgid = msgget(IPC_PRIVATE, PERM)) == -1) err_sys("msgget"); if ((pid = fork()) == -1) err_sys("fork"); else if (pi...
typedef struct AlccMakecallReqTag { char sCalledPtyNum[10]; }AlccMakecallReq; union Signal { AlccMakecallReq alccMakecallReq; }; typedef struct msgbody { long int message_type; union Signal sig; }MsgBody; 调用时msgsnd(msgid,(MsgBody*)&some_data,sizeof(some_data.sig.alccMakecallReq),0) 但是失败, 如果把msgbody改为 typedef struct msgbody { long int message_type; char test[100];...