0

I am working with queues with 2 diferent files on linux based system.

I am sending a struct by mq_send() and receiving with mq_receive() in another file.

When I used a char * that worked perfectly, but now, I put my struct, I convert it with (char *) and the sent happen, but I dont receive what I have to, and the number of bytes received in receive is always bytes received: 18446744073709551615

my struct is like:

struct men
{
    int a;
    int b;
    };

I also put the sizeof of the struct in mq_send() and mq_receive() and also in the attributes of the queue in .mq_msgsize.

I tried hard to find what is the problem, changing the sizes and whatever and I couldnt find the error.

Thank you!

difegui
  • 57
  • 1
  • 10

1 Answers1

0

18446744073709551615 is -1 mapped to an unsigned 64-bit integer. That indicates that mq_receive() failed. You'll need to look at errno to determine how it failed.

You shouldn't need to change the .mq_msgsize. I'd stick with mq_open(), as this is a pretty small structure.

Mike Andrews
  • 3,045
  • 18
  • 28