Boost.Asio provides Windows-specific classes that permit asynchronous read and write operations to be performed on HANDLEs that refer to regular files.
For example, to perform asynchronous operations on a file the following object may be created:
HANDLE handle = ::CreateFile(...); windows::random_access_handle file(my_io_context, handle);
Data may be read from or written to the handle using one of the
member functions. However, like the equivalent functions (
etc.) on streams, these functions are only required to transfer one or
more bytes in a single operation. Therefore free functions called read_at(), async_read_at(),
write_at() and async_write_at() have
been created to repeatedly call the corresponding
function until all data has been transferred.
HANDLEs are only available at compile
time when targeting Windows and only when the I/O completion port backend
is used (which is the default). A program may test for the macro
to determine whether they are supported.