Boost logo

Boost Users :

Subject: [Boost-users] [ASIO / Serialization] How to avoid the copy?
From: Dan Eaton (daniel.eaton_at_[hidden])
Date: 2009-05-25 10:53:47


Referring to the boost::asio "Serialization" example, and specifically to the file connection.hpp which handles serialization over sockets:

When new data is to be received, first the message header is read, which contains the number of bytes for the body. Storage must be allocated to receive the body, and is then passed into ::read as boost::asio::buffer. For the purpose of using Serialize, it must then be converted to an std::istream, (in the example above, istringstream). As shown in the example, this requires an extra copy to be held in memory for the std::string.

What's the best route to avoid this copy?


Dan Eaton
Software Developer
Acceleware Corp. (TSX-V:AXE)<>

Phone: +1.403.249.9099 Ext.295
Fax: +1.403.249.9881
Email: daniel.eaton_at_[hidden]<mailto:daniel.eaton_at_[hidden]>

Get superpowered!
Acceleware gets your products to market faster, better and stronger!

This e-mail may contain information that is privileged and confidential and subject to legal restrictions and penalties regarding its unauthorized disclosure or use. You are prohibited from copying, distributing or otherwise using this information if you are not the intended recipient. If you have received this e-mail in error, please notify us immediately by return e-mail and delete this e-mail and its attachments from your system. Thank you.
(c) 2008 Acceleware, Inc. All Rights Reserved

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at