I have an API which has a function that accepts an AsyncWriteStream as defined here:
http://www.boost.org/doc/libs/1_39_0/doc/html/boost_asio/reference/AsyncWriteStream.html
This is currently used (and works) to stream data to a tcp socket, using:
http://www.boost.org/doc/libs/1_41_0/doc/html/boost_asio/reference/basic_stream_socket.html
My question is that can this interface also be used to stream to a file on disk. I suspect the answer is yes but I would like to know how much effort is required and especially if there are existing implementations that support the interface.
So, to reiterate. The API function looks like:
template <class AsyncWriteStream>
void stream_read(AsyncWriteStream &stream, completion_callback CB) { ...
Internally the API writes data to AsyncWriteStream using boost::asio::async_write
. I want AsyncWriteStream to then be able to stream to both tcp and file socket. Perhaps my question could also be phrased "can a basic_stream_socket be created that streams to disk instead of tcp?"
I need this to work on both Windows and Linux.