[zeromq-dev] How to send/receive a custom C++ object via zeromq

Bjorn Reese breese at mail1.stofanet.dk
Wed Sep 25 20:52:21 CEST 2013


On 09/25/2013 06:43 PM, Riskybiz wrote:

> object and get it onto, across, and off the wire with zeromq.  Might
> this involve serializing to a memory buffer?  Hoped someone might be

Yes. The archive takes an std::ostream argument so instead of using
std::ofstream, you can just use std::ostringstream.

   std::ostringstream buffer;
   boost::archive::text_oarchive archive(buffer);
   // Do you serialization here
   archive << value;
   // The result can be extracted from the stringstream
   std::cout << buffer.str() << std::endl;

Likewise for the input archives, where you use std::istringstream
instead.




More information about the zeromq-dev mailing list