3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Stream descriptor service requirements</title>
5 <link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
7 <link rel="home" href="../../boost_asio.html" title="Boost.Asio">
8 <link rel="up" href="../reference.html" title="Reference">
9 <link rel="prev" href="SocketService.html" title="Socket service requirements">
10 <link rel="next" href="StreamHandleService.html" title="Stream handle service requirements">
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>
22 <div class="spirit-nav">
23 <a accesskey="p" href="SocketService.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.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="StreamHandleService.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
26 <div class="titlepage"><div><div><h3 class="title">
27 <a name="boost_asio.reference.StreamDescriptorService"></a><a class="link" href="StreamDescriptorService.html" title="Stream descriptor service requirements">Stream
28 descriptor service requirements</a>
29 </h3></div></div></div>
31 A stream descriptor service must meet the requirements for a <a class="link" href="DescriptorService.html" title="Descriptor service requirements">descriptor
32 service</a>, as well as the additional requirements listed below.
35 In the table below, <code class="computeroutput"><span class="identifier">X</span></code> denotes
36 a stream descriptor service class, <code class="computeroutput"><span class="identifier">a</span></code>
37 denotes a value of type <code class="computeroutput"><span class="identifier">X</span></code>,
38 <code class="computeroutput"><span class="identifier">b</span></code> denotes a value of type
39 <code class="computeroutput"><span class="identifier">X</span><span class="special">::</span><span class="identifier">implementation_type</span></code>, <code class="computeroutput"><span class="identifier">ec</span></code>
40 denotes a value of type <code class="computeroutput"><span class="identifier">error_code</span></code>,
41 <code class="computeroutput"><span class="identifier">mb</span></code> denotes a value satisfying
42 <a class="link" href="MutableBufferSequence.html" title="Mutable buffer sequence requirements">mutable buffer
43 sequence</a> requirements, <code class="computeroutput"><span class="identifier">rh</span></code>
44 denotes a value meeting <a class="link" href="ReadHandler.html" title="Read handler requirements"><code class="computeroutput"><span class="identifier">ReadHandler</span></code></a> requirements, <code class="computeroutput"><span class="identifier">cb</span></code> denotes a value satisfying <a class="link" href="ConstBufferSequence.html" title="Constant buffer sequence requirements">constant
45 buffer sequence</a> requirements, and <code class="computeroutput"><span class="identifier">wh</span></code>
46 denotes a value meeting <a class="link" href="WriteHandler.html" title="Write handler requirements"><code class="computeroutput"><span class="identifier">WriteHandler</span></code></a> requirements.
49 <a name="boost_asio.reference.StreamDescriptorService.t0"></a><p class="title"><b>Table 31. StreamDescriptorService requirements</b></p>
50 <div class="table-contents"><table class="table" summary="StreamDescriptorService requirements">
69 assertion/note<br> pre/post-condition
77 <code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">read_some</span><span class="special">(</span><span class="identifier">b</span><span class="special">,</span>
78 <span class="identifier">mb</span><span class="special">,</span>
79 <span class="identifier">ec</span><span class="special">);</span></code>
84 <code class="computeroutput"><span class="identifier">size_t</span></code>
89 pre: <code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">is_open</span><span class="special">(</span><span class="identifier">b</span><span class="special">)</span></code>.<br>
90 <br> Reads one or more bytes of data from a descriptor <code class="computeroutput"><span class="identifier">b</span></code>.<br> <br> The mutable buffer
91 sequence <code class="computeroutput"><span class="identifier">mb</span></code> specifies
92 memory where the data should be placed. The operation shall always
93 fill a buffer in the sequence completely before proceeding to the
94 next.<br> <br> If successful, returns the number of bytes read.
95 Otherwise returns <code class="computeroutput"><span class="number">0</span></code>.
96 If the total size of all buffers in the sequence <code class="computeroutput"><span class="identifier">mb</span></code> is <code class="computeroutput"><span class="number">0</span></code>,
97 the function shall return <code class="computeroutput"><span class="number">0</span></code>
98 immediately.<br> <br> If the operation completes due to graceful
99 connection closure by the peer, the operation shall fail with
100 <code class="computeroutput"><span class="identifier">error</span><span class="special">::</span><span class="identifier">eof</span></code>.
107 <code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">async_read_some</span><span class="special">(</span><span class="identifier">b</span><span class="special">,</span>
108 <span class="identifier">mb</span><span class="special">,</span>
109 <span class="identifier">rh</span><span class="special">);</span></code>
114 <code class="computeroutput"><span class="keyword">void</span></code>
119 pre: <code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">is_open</span><span class="special">(</span><span class="identifier">b</span><span class="special">)</span></code>.<br>
120 <br> Initiates an asynchronous operation to read one or more
121 bytes of data from a descriptor <code class="computeroutput"><span class="identifier">b</span></code>.
122 The operation is performed via the <code class="computeroutput"><span class="identifier">io_service</span></code>
123 object <code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">get_io_service</span><span class="special">()</span></code>
124 and behaves according to <a class="link" href="asynchronous_operations.html" title="Requirements on asynchronous operations">asynchronous
125 operation</a> requirements.<br> <br> The mutable buffer
126 sequence <code class="computeroutput"><span class="identifier">mb</span></code> specifies
127 memory where the data should be placed. The operation shall always
128 fill a buffer in the sequence completely before proceeding to the
129 next.<br> <br> The implementation shall maintain one or more
130 copies of <code class="computeroutput"><span class="identifier">mb</span></code> until
131 such time as the read operation no longer requires access to the
132 memory specified by the buffers in the sequence. The program must
133 ensure the memory is valid until:<br> <br> — the last copy of
134 <code class="computeroutput"><span class="identifier">mb</span></code> is destroyed,
135 or<br> <br> — the handler for the asynchronous operation is invoked,<br>
136 <br> whichever comes first. If the total size of all buffers
137 in the sequence <code class="computeroutput"><span class="identifier">mb</span></code>
138 is <code class="computeroutput"><span class="number">0</span></code>, the asynchronous
139 read operation shall complete immediately and pass <code class="computeroutput"><span class="number">0</span></code> as the argument to the handler
140 that specifies the number of bytes read.<br> <br> If the operation
141 completes due to graceful connection closure by the peer, the operation
142 shall fail with <code class="computeroutput"><span class="identifier">error</span><span class="special">::</span><span class="identifier">eof</span></code>.<br>
143 <br> If the operation completes successfully, the <code class="computeroutput"><span class="identifier">ReadHandler</span></code> object <code class="computeroutput"><span class="identifier">rh</span></code> is invoked with the number
144 of bytes transferred. Otherwise it is invoked with <code class="computeroutput"><span class="number">0</span></code>.
151 <code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">write_some</span><span class="special">(</span><span class="identifier">b</span><span class="special">,</span>
152 <span class="identifier">cb</span><span class="special">,</span>
153 <span class="identifier">ec</span><span class="special">);</span></code>
158 <code class="computeroutput"><span class="identifier">size_t</span></code>
163 pre: <code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">is_open</span><span class="special">(</span><span class="identifier">b</span><span class="special">)</span></code>.<br>
164 <br> Writes one or more bytes of data to a descriptor <code class="computeroutput"><span class="identifier">b</span></code>.<br> <br> The constant
165 buffer sequence <code class="computeroutput"><span class="identifier">cb</span></code>
166 specifies memory where the data to be written is located. The operation
167 shall always write a buffer in the sequence completely before proceeding
168 to the next.<br> <br> If successful, returns the number of
169 bytes written. Otherwise returns <code class="computeroutput"><span class="number">0</span></code>.
170 If the total size of all buffers in the sequence <code class="computeroutput"><span class="identifier">cb</span></code> is <code class="computeroutput"><span class="number">0</span></code>,
171 the function shall return <code class="computeroutput"><span class="number">0</span></code>
179 <code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">async_write_some</span><span class="special">(</span><span class="identifier">b</span><span class="special">,</span>
180 <span class="identifier">cb</span><span class="special">,</span>
181 <span class="identifier">wh</span><span class="special">);</span></code>
186 <code class="computeroutput"><span class="keyword">void</span></code>
191 pre: <code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">is_open</span><span class="special">(</span><span class="identifier">b</span><span class="special">)</span></code>.<br>
192 <br> Initiates an asynchronous operation to write one or more
193 bytes of data to a descriptor <code class="computeroutput"><span class="identifier">b</span></code>.
194 The operation is performed via the <code class="computeroutput"><span class="identifier">io_service</span></code>
195 object <code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">get_io_service</span><span class="special">()</span></code>
196 and behaves according to <a class="link" href="asynchronous_operations.html" title="Requirements on asynchronous operations">asynchronous
197 operation</a> requirements.<br> <br> The constant buffer
198 sequence <code class="computeroutput"><span class="identifier">cb</span></code> specifies
199 memory where the data to be written is located. The operation shall
200 always write a buffer in the sequence completely before proceeding
201 to the next.<br> <br> The implementation shall maintain one
202 or more copies of <code class="computeroutput"><span class="identifier">cb</span></code>
203 until such time as the write operation no longer requires access
204 to the memory specified by the buffers in the sequence. The program
205 must ensure the memory is valid until:<br> <br> — the last copy
206 of <code class="computeroutput"><span class="identifier">cb</span></code> is destroyed,
207 or<br> <br> — the handler for the asynchronous operation is invoked,<br>
208 <br> whichever comes first. If the total size of all buffers
209 in the sequence <code class="computeroutput"><span class="identifier">cb</span></code>
210 is <code class="computeroutput"><span class="number">0</span></code>, the asynchronous
211 operation shall complete immediately and pass <code class="computeroutput"><span class="number">0</span></code>
212 as the argument to the handler that specifies the number of bytes
213 read.<br> <br> If the operation completes successfully, the
214 <code class="computeroutput"><span class="identifier">WriteHandler</span></code> object
215 <code class="computeroutput"><span class="identifier">wh</span></code> is invoked with
216 the number of bytes transferred. Otherwise it is invoked with
217 <code class="computeroutput"><span class="number">0</span></code>.
224 <br class="table-break">
226 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
227 <td align="left"></td>
228 <td align="right"><div class="copyright-footer">Copyright © 2003-2014 Christopher M. Kohlhoff<p>
229 Distributed under the Boost Software License, Version 1.0. (See accompanying
230 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>)
235 <div class="spirit-nav">
236 <a accesskey="p" href="SocketService.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.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="StreamHandleService.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>