POSIX Message Queue - "Message too long" on send

32 Views Asked by At

I've got a client and a server process and I want to pass messages from the client to the server using POSIX message queue.

In my client code:

struct mq_attr attrs = {
    .mq_flags = 0,
    .mq_maxmsg = 10,
    .mq_curmsgs = 0,
    .mq_msgsize = 6200,
    };

    mqd_t mq = mq_open(POSIX_Q_NAME, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR, &attrs);

  if (mq == (mqd_t)-1) {
    perror("mq_open");
  }

  char* request = "Hello world";
  int res = mq_send(mq, request, strlen(request) + 1, 0);
  if (res == -1) {
    perror("mq_send");
  }

I am getting a res == -1, which is logging an mq_send error: Message too long. I'm struggling to understand how this can be. I'm currently running my client in isolation, so the server has not attempted to open the message queue first (and set the max message length to a diff value).

0

There are 0 best solutions below