/*************************************************************************** * * Linux IPC Message Queue * ************************************************************************/ #include #ifndef MSGQUEUE_H #define MSGQUEUE_H #define MB_SIZE 4096 #define KEY_LEN 8 const int defaultMode = 0666; const int readerType = 0; const int writeType = 1; const int msgBufferSize = 4096; const int NoWaitMode = IPC_NOWAIT; const int WaitMode = 0; const char dot = '.'; typedef struct { long mtype; char mtext[MB_SIZE]; } MBUF; class MQException: public exception { public: MQException(const string &message) throw(); ~MQException() throw(); const char *what() const throw() { return (MQmessage.c_str()); }; private: string MQmessage; }; class MsgQueue { int qid; MBUF mbuf; public: MsgQueue() throw (MQException); MsgQueue(string &name, long mtype = 0, int flag = 0) throw (MQException); int getId(); string read(long mtype = 0, int mode = 0) throw (MQException); void write(string &message, int mode = WaitMode, long mtype = 1) throw (MQException); }; #endif