stelmack@screamer.csee.usf.edu (Gregory M. Stelmack) (11/16/90)
I am trying to use the message passing facility of IPC on a Sun running
4.0.3. Unfortunately, I can't even get the msgget() call to work right. I
have checked the man pages to no avail, and no one around here has done
anything with this part of the OS (at least, not that I've found --
someone from our Tech Support is still looking for me). Does anyone out
there have this working, and if so would they mind sending me a small
chunk of code showing how they did it and what must be done to compile it?
My code currently looks something like this:
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
...
key_t GS_msgkey = 75;
int GS_msgid;
...
GS_msgid = msgget(GS_msgkey,0777|IPC_CREAT); /* Have tried: 0777&IPC_CREAT and
just IPC_CREAT, still same
error */
perror("server1");
if (GS_msgid==-1)
{
printf("server: could not get message queue\n");
exit(0);
}
perror prints: server1:Invalid Argument
then I get the "could not get message queue" message. I have tried lots of
combinations of ways of defining GS_msgkey (int, #define, hardcode) and
lots of values, plus the various ways of setting the flags mentioned
above. What stupid, stupid thing am I doing wrong????????
Thanks in advance,
-- Gregory M. Stelmack
-- stelmack@sol.csee.usf.edu