POSIX Message Queue
Hi
Can anyone tell me what is the third parameter in mq_open() prototype? mqd_t mq_open("/myQuue", O_RDWR|O_CREATE, ?,NULL); I don't want any attributes to be specified so I given NULL. |
It should be ehe mode argument: specifies the permissions to be placed on the new queue (for example: 0640)
|
Please help me in creating a simple message queue and communicate through it.
I don't want to provide any attributes to my queue. I have tried a small example, but it is not working this is the code which I tried. #include <stdio.h> #include <fcntl.h> /* For O_* constants */ #include <sys/stat.h> /* For mode constants */ #include <mqueue.h> int main() { // mqd_t mq_open(const char *name, int oflag, mode_t mode, struct mq_attr *attr); mqd_t myQueue; char msg_ptr[]="hai"; myQueue=mq_open("/myQueue1", O_RDWR|O_CREAT,0644, NULL); if(myQueue<0) printf("Failed"); mq_send(myQueue, msg_ptr, 4,1); getchar(); return 0; } #include <stdio.h> #include <fcntl.h> /* For O_* constants */ #include <sys/stat.h> /* For mode constants */ #include <mqueue.h> int main() { mqd_t myQueue; char msg_ptr[20]; myQueue=mq_open("/myQueue1", O_RDWR); mq_receive(myQueue, msg_ptr, 4, 1); printf("Received Message is %s\n",msg_ptr); return 0; } |
All times are GMT -5. The time now is 03:16 PM. |