mq_common.h
#pragma once
const char * mqfile = "/mqtest";
struct TEST {
int a;
int b;
char c;
double d;
};
mq_service.cpp
#include <mqueue.h>
#include <unistd.h>
#include <stdio.h>
#include <cassert>
#include <stdlib.h>
#include "mq_common.h"
#include <iostream>
int main () {
mqd_t mqd = mq_open (mqfile, O_CREAT | O_EXCL | O_WRONLY, 0600, NULL);
/* Ensure the creation was successful */
if (mqd == -1)
{
perror ("mq_open");
exit (1);
}
int si = 0;
int count = 0;
while(count++ < 100) {
TEST t;
t.a = 1 + si++;
t.b = 2 + si++;
t.c = 'c';
t.d = 0.5 + si++;
std::cout << "msg count = " << count <<