• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>write (2 of 16 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.html" title="write">
9<link rel="prev" href="overload1.html" title="write (1 of 16 overloads)">
10<link rel="next" href="overload3.html" title="write (3 of 16 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="../write.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.write.overload2"></a><a class="link" href="overload2.html" title="write (2 of 16 overloads)">write (2 of 16
28        overloads)</a>
29</h4></div></div></div>
30<p>
31          Write all of the supplied data to a stream before returning.
32        </p>
33<pre class="programlisting">template&lt;
34    typename <a class="link" href="../SyncWriteStream.html" title="Buffer-oriented synchronous write stream requirements">SyncWriteStream</a>,
35    typename <a class="link" href="../ConstBufferSequence.html" title="Constant buffer sequence requirements">ConstBufferSequence</a>&gt;
36std::size_t write(
37    SyncWriteStream &amp; s,
38    const ConstBufferSequence &amp; buffers,
39    boost::system::error_code &amp; ec,
40    typename enable_if&lt; is_const_buffer_sequence&lt; ConstBufferSequence &gt;::value &gt;::type *  = 0);
41</pre>
42<p>
43          This function is used to write a certain number of bytes of data to a stream.
44          The call will block until one of the 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 stream's
57          write_some function.
58        </p>
59<h6>
60<a name="boost_asio.reference.write.overload2.h0"></a>
61          <span class="phrase"><a name="boost_asio.reference.write.overload2.parameters"></a></span><a class="link" href="overload2.html#boost_asio.reference.write.overload2.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">s</span></dt>
67<dd><p>
68                The stream to which the data is to be written. The type must support
69                the SyncWriteStream concept.
70              </p></dd>
71<dt><span class="term">buffers</span></dt>
72<dd><p>
73                One or more buffers containing the data to be written. The sum of
74                the buffer sizes indicates the maximum number of bytes to write to
75                the stream.
76              </p></dd>
77<dt><span class="term">ec</span></dt>
78<dd><p>
79                Set to indicate what error occurred, if any.
80              </p></dd>
81</dl>
82</div>
83<h6>
84<a name="boost_asio.reference.write.overload2.h1"></a>
85          <span class="phrase"><a name="boost_asio.reference.write.overload2.return_value"></a></span><a class="link" href="overload2.html#boost_asio.reference.write.overload2.return_value">Return
86          Value</a>
87        </h6>
88<p>
89          The number of bytes transferred.
90        </p>
91<h6>
92<a name="boost_asio.reference.write.overload2.h2"></a>
93          <span class="phrase"><a name="boost_asio.reference.write.overload2.example"></a></span><a class="link" href="overload2.html#boost_asio.reference.write.overload2.example">Example</a>
94        </h6>
95<p>
96          To write a single data buffer use the <a class="link" href="../buffer.html" title="buffer"><code class="computeroutput">buffer</code></a>
97          function as follows:
98        </p>
99<pre class="programlisting">boost::asio::write(s, boost::asio::buffer(data, size), ec);
100</pre>
101<p>
102          See the <a class="link" href="../buffer.html" title="buffer"><code class="computeroutput">buffer</code></a>
103          documentation for information on writing multiple buffers in one go, and
104          how to use it with arrays, boost::array or std::vector.
105        </p>
106<h6>
107<a name="boost_asio.reference.write.overload2.h3"></a>
108          <span class="phrase"><a name="boost_asio.reference.write.overload2.remarks"></a></span><a class="link" href="overload2.html#boost_asio.reference.write.overload2.remarks">Remarks</a>
109        </h6>
110<p>
111          This overload is equivalent to calling:
112        </p>
113<pre class="programlisting">boost::asio::write(
114    s, buffers,
115    boost::asio::transfer_all(), ec);
116</pre>
117</div>
118<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
119<td align="left"></td>
120<td align="right"><div class="copyright-footer">Copyright © 2003-2020 Christopher M.
121      Kohlhoff<p>
122        Distributed under the Boost Software License, Version 1.0. (See accompanying
123        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>)
124      </p>
125</div></td>
126</tr></table>
127<hr>
128<div class="spirit-nav">
129<a accesskey="p" href="overload1.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../write.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>
130</div>
131</body>
132</html>
133