StreamHandleService.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  4. <title>Stream handle service requirements</title>
  5. <link rel="stylesheet" href="../../boostbook.css" type="text/css">
  6. <meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
  7. <link rel="home" href="../../index.html" title="Asio">
  8. <link rel="up" href="../reference.html" title="Reference">
  9. <link rel="prev" href="StreamDescriptorService.html" title="Stream descriptor service requirements">
  10. <link rel="next" href="StreamSocketService.html" title="Stream socket service requirements">
  11. </head>
  12. <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
  13. <table cellpadding="2" width="100%"><tr><td valign="top"><img alt="asio C++ library" width="250" height="60" src="../../asio.png"></td></tr></table>
  14. <hr>
  15. <div class="spirit-nav">
  16. <a accesskey="p" href="StreamDescriptorService.html"><img src="../../prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../home.png" alt="Home"></a><a accesskey="n" href="StreamSocketService.html"><img src="../../next.png" alt="Next"></a>
  17. </div>
  18. <div class="section">
  19. <div class="titlepage"><div><div><h3 class="title">
  20. <a name="asio.reference.StreamHandleService"></a><a class="link" href="StreamHandleService.html" title="Stream handle service requirements">Stream handle service
  21. requirements</a>
  22. </h3></div></div></div>
  23. <p>
  24. A stream handle service must meet the requirements for a <a class="link" href="HandleService.html" title="Handle service requirements">handle
  25. service</a>, as well as the additional requirements listed below.
  26. </p>
  27. <p>
  28. In the table below, <code class="computeroutput"><span class="identifier">X</span></code> denotes
  29. a stream handle service class, <code class="computeroutput"><span class="identifier">a</span></code>
  30. denotes a value of type <code class="computeroutput"><span class="identifier">X</span></code>,
  31. <code class="computeroutput"><span class="identifier">b</span></code> denotes a value of type
  32. <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>
  33. denotes a value of type <code class="computeroutput"><span class="identifier">error_code</span></code>,
  34. <code class="computeroutput"><span class="identifier">mb</span></code> denotes a value satisfying
  35. <a class="link" href="MutableBufferSequence.html" title="Mutable buffer sequence requirements">mutable buffer sequence</a>
  36. requirements, <code class="computeroutput"><span class="identifier">rh</span></code> denotes
  37. 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
  38. buffer sequence</a> requirements, and <code class="computeroutput"><span class="identifier">wh</span></code>
  39. 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.
  40. </p>
  41. <div class="table">
  42. <a name="asio.reference.StreamHandleService.t0"></a><p class="title"><b>Table&#160;32.&#160;StreamHandleService requirements</b></p>
  43. <div class="table-contents"><table class="table" summary="StreamHandleService requirements">
  44. <colgroup>
  45. <col>
  46. <col>
  47. <col>
  48. </colgroup>
  49. <thead><tr>
  50. <th>
  51. <p>
  52. expression
  53. </p>
  54. </th>
  55. <th>
  56. <p>
  57. return type
  58. </p>
  59. </th>
  60. <th>
  61. <p>
  62. assertion/note<br> pre/post-condition
  63. </p>
  64. </th>
  65. </tr></thead>
  66. <tbody>
  67. <tr>
  68. <td>
  69. <p>
  70. <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>
  71. <span class="identifier">mb</span><span class="special">,</span>
  72. <span class="identifier">ec</span><span class="special">);</span></code>
  73. </p>
  74. </td>
  75. <td>
  76. <p>
  77. <code class="computeroutput"><span class="identifier">size_t</span></code>
  78. </p>
  79. </td>
  80. <td>
  81. <p>
  82. 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>
  83. <br> Reads one or more bytes of data from a handle <code class="computeroutput"><span class="identifier">b</span></code>.<br> <br> The mutable buffer
  84. sequence <code class="computeroutput"><span class="identifier">mb</span></code> specifies
  85. memory where the data should be placed. The operation shall always
  86. fill a buffer in the sequence completely before proceeding to the
  87. next.<br> <br> If successful, returns the number of bytes read.
  88. Otherwise returns <code class="computeroutput"><span class="number">0</span></code>.
  89. 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>,
  90. the function shall return <code class="computeroutput"><span class="number">0</span></code>
  91. immediately.<br> <br> If the operation completes due to graceful
  92. connection closure by the peer, the operation shall fail with
  93. <code class="computeroutput"><span class="identifier">error</span><span class="special">::</span><span class="identifier">eof</span></code>.
  94. </p>
  95. </td>
  96. </tr>
  97. <tr>
  98. <td>
  99. <p>
  100. <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>
  101. <span class="identifier">mb</span><span class="special">,</span>
  102. <span class="identifier">rh</span><span class="special">);</span></code>
  103. </p>
  104. </td>
  105. <td>
  106. <p>
  107. <code class="computeroutput"><span class="keyword">void</span></code>
  108. </p>
  109. </td>
  110. <td>
  111. <p>
  112. 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>
  113. <br> Initiates an asynchronous operation to read one or more
  114. bytes of data from a handle <code class="computeroutput"><span class="identifier">b</span></code>.
  115. The operation is performed via the <code class="computeroutput"><span class="identifier">io_service</span></code>
  116. 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>
  117. and behaves according to <a class="link" href="asynchronous_operations.html" title="Requirements on asynchronous operations">asynchronous
  118. operation</a> requirements.<br> <br> The mutable buffer
  119. sequence <code class="computeroutput"><span class="identifier">mb</span></code> specifies
  120. memory where the data should be placed. The operation shall always
  121. fill a buffer in the sequence completely before proceeding to the
  122. next.<br> <br> The implementation shall maintain one or more
  123. copies of <code class="computeroutput"><span class="identifier">mb</span></code> until
  124. such time as the read operation no longer requires access to the
  125. memory specified by the buffers in the sequence. The program must
  126. ensure the memory is valid until:<br> <br> &#8212; the last copy of
  127. <code class="computeroutput"><span class="identifier">mb</span></code> is destroyed,
  128. or<br> <br> &#8212; the handler for the asynchronous operation is invoked,<br>
  129. <br> whichever comes first. If the total size of all buffers
  130. in the sequence <code class="computeroutput"><span class="identifier">mb</span></code>
  131. is <code class="computeroutput"><span class="number">0</span></code>, the asynchronous
  132. read operation shall complete immediately and pass <code class="computeroutput"><span class="number">0</span></code> as the argument to the handler
  133. that specifies the number of bytes read.<br> <br> If the operation
  134. completes due to graceful connection closure by the peer, the operation
  135. shall fail with <code class="computeroutput"><span class="identifier">error</span><span class="special">::</span><span class="identifier">eof</span></code>.<br>
  136. <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
  137. of bytes transferred. Otherwise it is invoked with <code class="computeroutput"><span class="number">0</span></code>.
  138. </p>
  139. </td>
  140. </tr>
  141. <tr>
  142. <td>
  143. <p>
  144. <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>
  145. <span class="identifier">cb</span><span class="special">,</span>
  146. <span class="identifier">ec</span><span class="special">);</span></code>
  147. </p>
  148. </td>
  149. <td>
  150. <p>
  151. <code class="computeroutput"><span class="identifier">size_t</span></code>
  152. </p>
  153. </td>
  154. <td>
  155. <p>
  156. 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>
  157. <br> Writes one or more bytes of data to a handle <code class="computeroutput"><span class="identifier">b</span></code>.<br> <br> The constant
  158. buffer sequence <code class="computeroutput"><span class="identifier">cb</span></code>
  159. specifies memory where the data to be written is located. The operation
  160. shall always write a buffer in the sequence completely before proceeding
  161. to the next.<br> <br> If successful, returns the number of
  162. bytes written. Otherwise returns <code class="computeroutput"><span class="number">0</span></code>.
  163. 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>,
  164. the function shall return <code class="computeroutput"><span class="number">0</span></code>
  165. immediately.
  166. </p>
  167. </td>
  168. </tr>
  169. <tr>
  170. <td>
  171. <p>
  172. <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>
  173. <span class="identifier">cb</span><span class="special">,</span>
  174. <span class="identifier">wh</span><span class="special">);</span></code>
  175. </p>
  176. </td>
  177. <td>
  178. <p>
  179. <code class="computeroutput"><span class="keyword">void</span></code>
  180. </p>
  181. </td>
  182. <td>
  183. <p>
  184. 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>
  185. <br> Initiates an asynchronous operation to write one or more
  186. bytes of data to a handle <code class="computeroutput"><span class="identifier">b</span></code>.
  187. The operation is performed via the <code class="computeroutput"><span class="identifier">io_service</span></code>
  188. 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>
  189. and behaves according to <a class="link" href="asynchronous_operations.html" title="Requirements on asynchronous operations">asynchronous
  190. operation</a> requirements.<br> <br> The constant buffer
  191. sequence <code class="computeroutput"><span class="identifier">cb</span></code> specifies
  192. memory where the data to be written is located. The operation shall
  193. always write a buffer in the sequence completely before proceeding
  194. to the next.<br> <br> The implementation shall maintain one
  195. or more copies of <code class="computeroutput"><span class="identifier">cb</span></code>
  196. until such time as the write operation no longer requires access
  197. to the memory specified by the buffers in the sequence. The program
  198. must ensure the memory is valid until:<br> <br> &#8212; the last copy
  199. of <code class="computeroutput"><span class="identifier">cb</span></code> is destroyed,
  200. or<br> <br> &#8212; the handler for the asynchronous operation is invoked,<br>
  201. <br> whichever comes first. If the total size of all buffers
  202. in the sequence <code class="computeroutput"><span class="identifier">cb</span></code>
  203. is <code class="computeroutput"><span class="number">0</span></code>, the asynchronous
  204. operation shall complete immediately and pass <code class="computeroutput"><span class="number">0</span></code>
  205. as the argument to the handler that specifies the number of bytes
  206. read.<br> <br> If the operation completes successfully, the
  207. <code class="computeroutput"><span class="identifier">WriteHandler</span></code> object
  208. <code class="computeroutput"><span class="identifier">wh</span></code> is invoked with
  209. the number of bytes transferred. Otherwise it is invoked with
  210. <code class="computeroutput"><span class="number">0</span></code>.
  211. </p>
  212. </td>
  213. </tr>
  214. </tbody>
  215. </table></div>
  216. </div>
  217. <br class="table-break">
  218. </div>
  219. <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
  220. <td align="left"></td>
  221. <td align="right"><div class="copyright-footer">Copyright &#169; 2003-2014 Christopher M. Kohlhoff<p>
  222. Distributed under the Boost Software License, Version 1.0. (See accompanying
  223. 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>)
  224. </p>
  225. </div></td>
  226. </tr></table>
  227. <hr>
  228. <div class="spirit-nav">
  229. <a accesskey="p" href="StreamDescriptorService.html"><img src="../../prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../home.png" alt="Home"></a><a accesskey="n" href="StreamSocketService.html"><img src="../../next.png" alt="Next"></a>
  230. </div>
  231. </body>
  232. </html>