I am new to IPC. I want to use different IPC mechanisms in my project. Depending upon the performance and requirements, I need to change the IPC mechanisms to message queue/shared memory or sockets.
I would like to use common APIs for sending, receiving and initialising the IPC even if the IPC mechanism changes internally.
Does any open source wrapper library or common interface available in C++? Or do I need to develop my own APIs to define this? I would like to refer if any already available interfaces for these.
I am looking something similar below
and many more
Thanks in Advance
There are many C++ libraries for IPC (asking for libs on SO is off-topic ). I was working with
and they were quite OK for me. There is no such thing as "unified IPC interface" for C++, you must just think about what you need exactly and design the interface according to your needs. I usually work with something similar to the interface below:
class AbstractIPC
{
public:
virtual ~AbstractIPC() = default;
virtual bool open() = 0;
virtual bool close() = 0;
virtual int send(const uint8_t* data, size_t, length) = 0;
virtual int receive(uint8_t* data, size_t, length) = 0;
};
The reason for not using std::vector<uint8_t>
or std::string
is the compatibility with other components, potentially written in C.
Not super precise answer, but I hope it will give you some insight where to start.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.