LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-16-2013, 06:48 AM   #1
LinuxDreams
LQ Newbie
 
Registered: Jul 2013
Location: Bangalore, India
Distribution: Fedora
Posts: 8

Rep: Reputation: Disabled
Cool 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.
 
Old 08-16-2013, 06:56 AM   #2
kooru
Senior Member
 
Registered: Sep 2012
Posts: 1,385

Rep: Reputation: 275Reputation: 275Reputation: 275
It should be ehe mode argument: specifies the permissions to be placed on the new queue (for example: 0640)
 
Old 08-20-2013, 05:35 AM   #3
LinuxDreams
LQ Newbie
 
Registered: Jul 2013
Location: Bangalore, India
Distribution: Fedora
Posts: 8

Original Poster
Rep: Reputation: Disabled
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;
}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help:program hang stuck there signal handling on POSIX Message Queue UNIX C pr ouou Programming 1 06-14-2011 11:38 PM
Posix Message queue, mq_receive process conflict mbalkan Programming 0 11-12-2009 11:15 AM
how to clear a posix message queue navalbabu Programming 5 01-11-2008 01:37 PM
does rh9.0 support POSIX message queue? simon_qwl Programming 1 07-22-2005 05:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration