Hello,
I need to implement a simple over-the-network interaction in C++ and I've been wondering whether there are libraries that do that already. My protocol basically sends messages and receives responses. Each message is just a set of 3-4 values of basic data types. I would like to find a library (or libraries) that can do one or more of the following:
- Serialize the values into an efficient byte array (I cannot use text based serialization).
- Send the message and wait for the result (it can either lock or receive the response asynchronously, I don't care).
- It has to be able to correlate between the sent message and the response.
Ideally I would like to be able to write something like this:
// On the sending side
bool send(const string& str, int x, char y)
{
Message msg;
msg << str << x << y;
// Lock until the response arrives
return cool_library::send(address, msg);
}
// On the receiving side
bool receive(Message& msg)
{
string str;
int x;
char y;
msg >> str;
msg >> x;
msg >> y;
if (some conditions...)
return true; // the message was handled successfully
else
return false;
}
Pay attention that cool_library::send returns true not when the message was successfully sent but when the other side responded with success result. All this lengthy explanation is just to show that I need a simple functionality. Nothing fancy. I can even send and receive the buffers myself but I need something that can correlate messages to responses. I don't want to go for RPC because it seems to me as an overkill.
Thank you.