1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Random-Access HANDLEs</title> 5<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../../../boost_asio.html" title="Boost.Asio"> 8<link rel="up" href="../windows.html" title="Windows-Specific Functionality"> 9<link rel="prev" href="stream_handle.html" title="Stream-Oriented HANDLEs"> 10<link rel="next" href="object_handle.html" title="Object HANDLEs"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr> 14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> 15<td align="center"><a href="../../../../../index.html">Home</a></td> 16<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> 17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 19<td align="center"><a href="../../../../../more/index.htm">More</a></td> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="stream_handle.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../windows.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../boost_asio.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="object_handle.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h4 class="title"> 27<a name="boost_asio.overview.windows.random_access_handle"></a><a class="link" href="random_access_handle.html" title="Random-Access HANDLEs">Random-Access 28 HANDLEs</a> 29</h4></div></div></div> 30<p> 31 Boost.Asio provides Windows-specific classes that permit asynchronous read 32 and write operations to be performed on HANDLEs that refer to regular files. 33 </p> 34<p> 35 For example, to perform asynchronous operations on a file the following 36 object may be created: 37 </p> 38<pre class="programlisting">HANDLE handle = ::CreateFile(...); 39windows::random_access_handle file(my_io_context, handle); 40</pre> 41<p> 42 Data may be read from or written to the handle using one of the <code class="computeroutput">read_some_at()</code>, 43 <code class="computeroutput">async_read_some_at()</code>, <code class="computeroutput">write_some_at()</code> or <code class="computeroutput">async_write_some_at()</code> 44 member functions. However, like the equivalent functions (<code class="computeroutput">read_some()</code>, 45 etc.) on streams, these functions are only required to transfer one or 46 more bytes in a single operation. Therefore free functions called <a class="link" href="../../reference/read_at.html" title="read_at">read_at()</a>, <a class="link" href="../../reference/async_read_at.html" title="async_read_at">async_read_at()</a>, 47 <a class="link" href="../../reference/write_at.html" title="write_at">write_at()</a> and <a class="link" href="../../reference/async_write_at.html" title="async_write_at">async_write_at()</a> have 48 been created to repeatedly call the corresponding <code class="literal"><span class="bold"><strong>*</strong></span>_some_at()</code> 49 function until all data has been transferred. 50 </p> 51<h6> 52<a name="boost_asio.overview.windows.random_access_handle.h0"></a> 53 <span class="phrase"><a name="boost_asio.overview.windows.random_access_handle.see_also"></a></span><a class="link" href="random_access_handle.html#boost_asio.overview.windows.random_access_handle.see_also">See 54 Also</a> 55 </h6> 56<p> 57 <a class="link" href="../../reference/windows__random_access_handle.html" title="windows::random_access_handle">windows::random_access_handle</a>. 58 </p> 59<h6> 60<a name="boost_asio.overview.windows.random_access_handle.h1"></a> 61 <span class="phrase"><a name="boost_asio.overview.windows.random_access_handle.notes"></a></span><a class="link" href="random_access_handle.html#boost_asio.overview.windows.random_access_handle.notes">Notes</a> 62 </h6> 63<p> 64 Windows random-access <code class="computeroutput">HANDLE</code>s are only available at compile 65 time when targeting Windows and only when the I/O completion port backend 66 is used (which is the default). A program may test for the macro <code class="computeroutput">BOOST_ASIO_HAS_WINDOWS_RANDOM_ACCESS_HANDLE</code> 67 to determine whether they are supported. 68 </p> 69</div> 70<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 71<td align="left"></td> 72<td align="right"><div class="copyright-footer">Copyright © 2003-2020 Christopher M. 73 Kohlhoff<p> 74 Distributed under the Boost Software License, Version 1.0. (See accompanying 75 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 76 </p> 77</div></td> 78</tr></table> 79<hr> 80<div class="spirit-nav"> 81<a accesskey="p" href="stream_handle.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../windows.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../boost_asio.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="object_handle.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> 82</div> 83</body> 84</html> 85