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