LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-08-2007, 09:18 AM   #1
mageshvan
LQ Newbie
 
Registered: Aug 2007
Posts: 11

Rep: Reputation: 0
mq_open error


Hi,

Am creating a msgqueue using mq_open
</code>
main()
{
struct mq_attr attr; /* message queue attributes structure */
memset(&_attr,0,sizeof(struct mq_attr));
attr.mq_maxmsg= 10;
attr.mq_msgsize= 20;

msg.flag = HS_FWK_MSGQ_FLAGS;
mq_open("/h_qname",O_CREAT|O_RDWR|O_EXCL|O_NONBLOCK, 00666,&attr);

then sending message using
mq_send(....)
}


Again opening the message queue using the name to receive the message...but mq_open fails here...
main()
{
struct mq_attr attr; /* message queue attributes structure */
memset(&_attr,0,sizeof(struct mq_attr));
attr.mq_maxmsg= 10;
attr.mq_msgsize= 20;

msg.flag = HS_FWK_MSGQ_FLAGS;
mq_open("h_qname",O_CREAT|O_RDONLY, 00666,&attr);

}
<code>


I tried with O_RDWR flag too... but thatz also failing... i couldn't find out where exactly am going wrong... could somebody help me on this.

Thanks.
 
Old 10-08-2007, 12:05 PM   #2
orgcandman
Member
 
Registered: May 2002
Location: new hampshire
Distribution: Fedora, RHEL
Posts: 600

Rep: Reputation: 110Reputation: 110
Firstly, your queue in the second like does not have the required "/" precursor.

If it were me, I'd do the following:

For the process which will be reading the MQ:

Code:
mqid = mq_open ("/h_queue",
                O_CREAT | O_RDWR | O_EXCL | S_IRWXU | S_IRWXG | S_IRWXO,
                0, NULL);
For the process which will be sending the message to that queue:

Code:
mqid = mq_open("/hqueue", O_WRONLY, 0, NULL);
-Aaron
 
  


Reply



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
Suse CUPS error: cups(File)DoRequest error:client-error-bad-request smdonelan Linux - Hardware 6 04-17-2007 06:46 PM
mq_open error ('invalid arg') on RHEL4 lambert_anne Programming 1 03-14-2007 08:12 AM
Error message received from system Error while reading filter description for true Steel_J Linux - Software 2 03-04-2006 06:10 PM
mq_open fails on Suse 9.2 / 9.3 supaflav Programming 1 11-04-2005 01:12 PM
updating new installation of 9.3 ERROR...ERROR...ERROR Morbid SUSE / openSUSE 3 08-15-2005 11:22 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:53 PM.

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