I have a requirment to have communication between two processes using message queues. One process sends the request to another process and other process sends response.
For example one of the request is list all the filenames opened by the process. I have made interface structure as
#define LIST_NAMES 1
#define LIST_FILE_NAMES_RESP 2
struct sFileStruct {
unsigned int uiCommand;
unsigned long ulNoOfBytes; // Number of bytes to be parsed in cha* pointer below
char* pRecvData; // file names packed here in response.
};
sFileStruct inData;
// I am filling the data.
int inSize = sizeof(inData);
mq_send(m_qSendDesc, (char*)&inData, inSize, inPriority);
I think problem with above design is that as file names legth is changing char* pointer pointing to data is different, but size of structure is always constant, so receiver is not receving all the data and receiver is crashing while accessing the char* pointer.
I want to sent full data in one mq_send, and don't want to have static array inside structure. Is there any other way using message queues we can achieve this.
Please provide your inputs. Thanks