Send and receiving compressed files with boost over socket
<p>In my project, read and write messages over socket are compressed with Zlib Filters of boost, i would like to know how to do the same with <strong>files</strong>.
what better way for better speed? Save the data in buffer without use hard disk?</p>

<p>I'm having trouble to transferring files using boost, so any help and examples are welcome.</p>

<p>I am using the following code to send compressed messages:</p>

<pre><code>std::string data_
std::stringstream compressed;
std::stringstream original;

original &lt;&lt; data_;

boost::iostreams::filtering_streambuf&lt;boost::iostreams::input&gt; out;
out.push(boost::iostreams::zlib_compressor());
out.push(original);
boost::iostreams::copy(out, compressed);

data_ = compressed.str();
boost::asio::write(socket_, boost::asio::buffer(data_ + '\n'));
</code></pre>

<p><strong>EDIT:</strong></p>

<p>I want to know how to compress a file without having to save a compressed copy in the HD. Saving your bytes directly into a buffer and then send to the socket. Server-side must receive the file and decompress</p>