title: Looking for a library for simple protocol implementation
body: <p>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:</p>
  
  <ol>
  <li>Serialize the values into an efficient byte array (I cannot use text based serialization).</li>
  <li>Send the message and wait for the result (it can either lock or receive the response asynchronously, I don't care).</li>
  <li>It has to be able to correlate between the sent message and the response.</li>
  </ol>
  
  <p>Ideally I would like to be able to write something like this:</p>
  
  <pre><code>// On the sending side
  bool send(const string&amp; str, int x, char y)
  {
      Message msg;
      msg  &lt;&lt; str &lt;&lt; x &lt;&lt; y;
  
      // Lock until the response arrives
      return cool_library::send(address, msg);
  }
  
  // On the receiving side
  bool receive(Message&amp; msg)
  {
      string str; 
      int x; 
      char y;
  
      msg &gt;&gt; str;
      msg &gt;&gt; x;
      msg &gt;&gt; y;
  
      if (some conditions...)
          return true; // the message was handled successfully
      else
          return false;
  }
  </code></pre>
  
  <p>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.</p>
  
  <p>Thank you.</p>