1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>read_at (2 of 8 overloads)</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="../read_at.html" title="read_at"> 9<link rel="prev" href="overload1.html" title="read_at (1 of 8 overloads)"> 10<link rel="next" href="overload3.html" title="read_at (3 of 8 overloads)"> 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="overload1.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../read_at.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="overload3.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.reference.read_at.overload2"></a><a class="link" href="overload2.html" title="read_at (2 of 8 overloads)">read_at (2 28 of 8 overloads)</a> 29</h4></div></div></div> 30<p> 31 Attempt to read a certain amount of data at the specified offset before 32 returning. 33 </p> 34<pre class="programlisting">template< 35 typename <a class="link" href="../SyncRandomAccessReadDevice.html" title="Buffer-oriented synchronous random-access read device requirements">SyncRandomAccessReadDevice</a>, 36 typename <a class="link" href="../MutableBufferSequence.html" title="Mutable buffer sequence requirements">MutableBufferSequence</a>> 37std::size_t read_at( 38 SyncRandomAccessReadDevice & d, 39 uint64_t offset, 40 const MutableBufferSequence & buffers, 41 boost::system::error_code & ec); 42</pre> 43<p> 44 This function is used to read a certain number of bytes of data from a 45 random access device at the specified offset. The call will block until 46 one of the following conditions is true: 47 </p> 48<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 49<li class="listitem"> 50 The supplied buffers are full. That is, the bytes transferred is equal 51 to the sum of the buffer sizes. 52 </li> 53<li class="listitem"> 54 An error occurred. 55 </li> 56</ul></div> 57<p> 58 This operation is implemented in terms of zero or more calls to the device's 59 read_some_at function. 60 </p> 61<h6> 62<a name="boost_asio.reference.read_at.overload2.h0"></a> 63 <span class="phrase"><a name="boost_asio.reference.read_at.overload2.parameters"></a></span><a class="link" href="overload2.html#boost_asio.reference.read_at.overload2.parameters">Parameters</a> 64 </h6> 65<div class="variablelist"> 66<p class="title"><b></b></p> 67<dl class="variablelist"> 68<dt><span class="term">d</span></dt> 69<dd><p> 70 The device from which the data is to be read. The type must support 71 the SyncRandomAccessReadDevice concept. 72 </p></dd> 73<dt><span class="term">offset</span></dt> 74<dd><p> 75 The offset at which the data will be read. 76 </p></dd> 77<dt><span class="term">buffers</span></dt> 78<dd><p> 79 One or more buffers into which the data will be read. The sum of 80 the buffer sizes indicates the maximum number of bytes to read from 81 the device. 82 </p></dd> 83<dt><span class="term">ec</span></dt> 84<dd><p> 85 Set to indicate what error occurred, if any. 86 </p></dd> 87</dl> 88</div> 89<h6> 90<a name="boost_asio.reference.read_at.overload2.h1"></a> 91 <span class="phrase"><a name="boost_asio.reference.read_at.overload2.return_value"></a></span><a class="link" href="overload2.html#boost_asio.reference.read_at.overload2.return_value">Return Value</a> 92 </h6> 93<p> 94 The number of bytes transferred. 95 </p> 96<h6> 97<a name="boost_asio.reference.read_at.overload2.h2"></a> 98 <span class="phrase"><a name="boost_asio.reference.read_at.overload2.example"></a></span><a class="link" href="overload2.html#boost_asio.reference.read_at.overload2.example">Example</a> 99 </h6> 100<p> 101 To read into a single data buffer use the <a class="link" href="../buffer.html" title="buffer"><code class="computeroutput">buffer</code></a> 102 function as follows: 103 </p> 104<pre class="programlisting">boost::asio::read_at(d, 42, 105 boost::asio::buffer(data, size), ec); 106</pre> 107<p> 108 See the <a class="link" href="../buffer.html" title="buffer"><code class="computeroutput">buffer</code></a> 109 documentation for information on reading into multiple buffers in one go, 110 and how to use it with arrays, boost::array or std::vector. 111 </p> 112<h6> 113<a name="boost_asio.reference.read_at.overload2.h3"></a> 114 <span class="phrase"><a name="boost_asio.reference.read_at.overload2.remarks"></a></span><a class="link" href="overload2.html#boost_asio.reference.read_at.overload2.remarks">Remarks</a> 115 </h6> 116<p> 117 This overload is equivalent to calling: 118 </p> 119<pre class="programlisting">boost::asio::read_at( 120 d, 42, buffers, 121 boost::asio::transfer_all(), ec); 122</pre> 123</div> 124<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 125<td align="left"></td> 126<td align="right"><div class="copyright-footer">Copyright © 2003-2020 Christopher M. 127 Kohlhoff<p> 128 Distributed under the Boost Software License, Version 1.0. (See accompanying 129 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>) 130 </p> 131</div></td> 132</tr></table> 133<hr> 134<div class="spirit-nav"> 135<a accesskey="p" href="overload1.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../read_at.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="overload3.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> 136</div> 137</body> 138</html> 139