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 files. what better way for better speed? Save the data in buffer without use hard disk?
I'm having trouble to transferring files using boost, so any help and examples are welcome.
I am using the following code to send compressed messages:
std::string data_
std::stringstream compressed;
std::stringstream original;
original << data_;
boost::iostreams::filtering_streambuf<boost::iostreams::input> 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'));
EDIT:
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