27#include <utils/ipc/msg.h>
28#include <utils/ipc/msg_exceptions.h>
35class IPCMessageQueueData
75 data =
new IPCMessageQueueData();
81 data->msgflg |= IPC_CREAT;
84 data->key = ftok(path,
id);
85 data->msgqid = msgget(data->key, data->msgflg);
99 data =
new IPCMessageQueueData();
105 data->msgflg |= IPC_CREAT;
109 data->msgqid = msgget(data->key, data->msgflg);
116 msgctl(data->msgqid, IPC_RMID, 0);
130 if (data->msgqid == -1) {
131 data->msgqid = msgget(data->key, data->msgflg);
132 if (data->msgqid == -1) {
136 if (msgctl(data->msgqid, IPC_STAT, &m) != -1) {
145 if (msgctl(data->msgqid, IPC_STAT, &m) != -1) {
172 if (data->msgqid == -1)
175 if (msgrcv(data->msgqid, (
struct msgbuf *)msg, data_size -
sizeof(
long),
mtype, IPC_NOWAIT)
177 if ((errno == EIDRM) || (errno == EINVAL)) {
180 if (errno == E2BIG) {
204 if (data->msgqid == -1)
208 msgrcv(data->msgqid, (
struct msgbuf *)msg, max_data_size -
sizeof(
long), 0, IPC_NOWAIT))
210 if ((errno == EIDRM) || (errno == EINVAL)) {
229 if (data->msgqid == -1)
232 if (msgsnd(data->msgqid, msg, data_size -
sizeof(
long), IPC_NOWAIT) == -1) {
233 if (errno == EIDRM) {
bool recvNext(MessageStruct *msg, unsigned int max_data_size, int *data_size)
Receive messages from this queue of any type.
~IPCMessageQueue()
Destructor.
bool recv(long mtype, MessageStruct *msg, unsigned int data_size)
Receive messages from this queue of the given message type.
static const int MaxMessageSize
Maximum size of a message.
bool isValid()
Check if the message queue is valid If the queue could not be opened yet (for example if you gave cre...
static long mtype(char *buffer)
Get the message type.
bool destroy_on_delete
destroy this message queue on delete?
bool send(MessageStruct *msg, unsigned int data_size)
Receive messages from this queue of the given message type.
IPCMessageQueue(const char *path, char id, bool create=false, bool destroy_on_delete=false)
Create or open a message queue If a message key with the given identification criteria exists it is o...
Message did not fit into buffer.
Fawkes library namespace.
This is the struct of the messages that has to be fed to send and receive methods.