Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using mq_open to send and receive messages

Status
Not open for further replies.

lk5990

Programmer
Jul 2, 2001
7
US
I'm trying to write code using the mqueue library. I'm working on UNIX (solaris), but I can't get me code to run at all. This is a snippit of what I have..

#define PMODE 0666

int main()
{
int i;
mqd_t mqfd;
struct mq_attr attr;
int open_flags = 0;

attr.mq_maxmsg = 20;
attr.mq_msgsize = 30;
attr.mq_flags = 0;
open_flags = O_RDONLY|O_CREAT
mqfd = mq_open("myque",open_flags,PMODE,&attr);
if (mqfd ==(mqd_t)-1)
{
perror("mq_open failure from main");
exit(0);
};
/* more ....*/
}

It compiles, and I know myque doesn't exist. I get an 'invalid argument' error. What am I doing wrong?

Thanks!

 
The first char of the name of the string that describes message Q should be a '/' so u shud write it as "/myque" and any other char. in the string cannot be a '/'.
Also see the man page on mq_open to ge more information.

Regards
Nam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top