Last few days I play with asio. I try to read files asynchronously using asio, but asio doesn’t work properly (I think) in this case.
For example, simple code (see below) doesn’t work as I expect.
asio::windows::basic_stream_handle<> handle_; |
_Winnie C++ Colorizer |
I expect that asio::async_read reads whole file into buffer buf_, but instead this asio fills buffer with block of data read from begin of file.
Alex advise me try version from cvs.sourceforge. In that version windows::basic_stream_handle doesn’t work properly too, but cvs version contains windows::basic_random_access_handle. Using this class we can build working stream that allow us read files sequentially or randomly. For example we can build following sequential stream:
struct random_handle_wrapper |
_Winnie C++ Colorizer |
And read_handler that uses this stream:
void read_handler (asio::error_code ec, size_t transferred) |
_Winnie C++ Colorizer |
No comments:
Post a Comment