Re: Message queue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Prasanta Sadhukhan wrote:

> I was trying to use the message queue implementation of linux through a 
> simple client/server program.
> The client will get text from stdin and send to server through message 
> queue and server will convert to upper case and resend to back to client
> Attached is the client and server program I used
> However, while sending in client and receiving in server, I am getting 
> errno as 13(EACCESS). Can anyone tell me what I need to do extra?

For a start, the side which creates the message queue (probably the
server) needs to set the permissions, e.g.:

	#include <sys/stat.h>
	...
	toinput_id=msgget(key_out, IPC_CREAT|S_IRUSR|S_IWUSR);
	...
	tooutput_id=msgget(key_in, IPC_CREAT|S_IRUSR|S_IWUSR);

Otherwise, access will be refused, hence EACCESS.

Some other issues:

The third argument to msgrcv() needs to be the size of the buffer,
e.g. sizeof(text) not strlen(text).

The return value from main should be non-negative, zero for success
and greater than zero for failure. In practice, a value of -1 will
typically result in an exit code of 255 due to being truncated to 8
bits.

-- 
Glynn Clements <glynn@xxxxxxxxxxxxxxxxxx>
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux