StreamSocketService.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  4. <title>Stream socket 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="StreamHandleService.html" title="Stream handle service requirements">
  10. <link rel="next" href="SyncRandomAccessReadDevice.html" title="Buffer-oriented synchronous random-access read device 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="StreamHandleService.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="SyncRandomAccessReadDevice.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.StreamSocketService"></a><a class="link" href="StreamSocketService.html" title="Stream socket service requirements">Stream socket service
  21. requirements</a>
  22. </h3></div></div></div>
  23. <p>
  24. A stream socket service must meet the requirements for a <a class="link" href="SocketService.html" title="Socket service requirements">socket
  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 socket 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">f</span></code> denotes a value of type
  35. <code class="computeroutput"><span class="identifier">socket_base</span><span class="special">::</span><span class="identifier">message_flags</span></code>, <code class="computeroutput"><span class="identifier">mb</span></code>
  36. denotes a value satisfying <a class="link" href="MutableBufferSequence.html" title="Mutable buffer sequence requirements">mutable
  37. buffer sequence</a> requirements, <code class="computeroutput"><span class="identifier">rh</span></code>
  38. 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
  39. buffer sequence</a> requirements, and <code class="computeroutput"><span class="identifier">wh</span></code>
  40. 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.
  41. </p>
  42. <div class="table">
  43. <a name="asio.reference.StreamSocketService.t0"></a><p class="title"><b>Table&#160;33.&#160;StreamSocketService requirements</b></p>
  44. <div class="table-contents"><table class="table" summary="StreamSocketService requirements">
  45. <colgroup>
  46. <col>
  47. <col>
  48. <col>
  49. </colgroup>
  50. <thead><tr>
  51. <th>
  52. <p>
  53. expression
  54. </p>
  55. </th>
  56. <th>
  57. <p>
  58. return type
  59. </p>
  60. </th>
  61. <th>
  62. <p>
  63. assertion/note<br> pre/post-condition
  64. </p>
  65. </th>
  66. </tr></thead>
  67. <tbody>
  68. <tr>
  69. <td>
  70. <p>
  71. <code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">receive</span><span class="special">(</span><span class="identifier">b</span><span class="special">,</span>
  72. <span class="identifier">mb</span><span class="special">,</span>
  73. <span class="identifier">f</span><span class="special">,</span>
  74. <span class="identifier">ec</span><span class="special">);</span></code>
  75. </p>
  76. </td>
  77. <td>
  78. <p>
  79. <code class="computeroutput"><span class="identifier">size_t</span></code>
  80. </p>
  81. </td>
  82. <td>
  83. <p>
  84. 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>
  85. <br> Reads one or more bytes of data from a connected socket
  86. <code class="computeroutput"><span class="identifier">b</span></code>.<br> <br>
  87. The mutable buffer sequence <code class="computeroutput"><span class="identifier">mb</span></code>
  88. specifies memory where the data should be placed. The operation
  89. shall always fill a buffer in the sequence completely before proceeding
  90. to the next.<br> <br> If successful, returns the number of
  91. bytes read. Otherwise returns <code class="computeroutput"><span class="number">0</span></code>.
  92. 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>,
  93. the function shall return <code class="computeroutput"><span class="number">0</span></code>
  94. immediately.<br> <br> If the operation completes due to graceful
  95. connection closure by the peer, the operation shall fail with
  96. <code class="computeroutput"><span class="identifier">error</span><span class="special">::</span><span class="identifier">eof</span></code>.
  97. </p>
  98. </td>
  99. </tr>
  100. <tr>
  101. <td>
  102. <p>
  103. <code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">async_receive</span><span class="special">(</span><span class="identifier">b</span><span class="special">,</span>
  104. <span class="identifier">mb</span><span class="special">,</span>
  105. <span class="identifier">f</span><span class="special">,</span>
  106. <span class="identifier">rh</span><span class="special">);</span></code>
  107. </p>
  108. </td>
  109. <td>
  110. <p>
  111. <code class="computeroutput"><span class="keyword">void</span></code>
  112. </p>
  113. </td>
  114. <td>
  115. <p>
  116. 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>
  117. <br> Initiates an asynchronous operation to read one or more
  118. bytes of data from a connected socket <code class="computeroutput"><span class="identifier">b</span></code>.
  119. The operation is performed via the <code class="computeroutput"><span class="identifier">io_service</span></code>
  120. 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>
  121. and behaves according to <a class="link" href="asynchronous_operations.html" title="Requirements on asynchronous operations">asynchronous
  122. operation</a> requirements.<br> <br> The mutable buffer
  123. sequence <code class="computeroutput"><span class="identifier">mb</span></code> specifies
  124. memory where the data should be placed. The operation shall always
  125. fill a buffer in the sequence completely before proceeding to the
  126. next.<br> <br> The implementation shall maintain one or more
  127. copies of <code class="computeroutput"><span class="identifier">mb</span></code> until
  128. such time as the read operation no longer requires access to the
  129. memory specified by the buffers in the sequence. The program must
  130. ensure the memory is valid until:<br> <br> &#8212; the last copy of
  131. <code class="computeroutput"><span class="identifier">mb</span></code> is destroyed,
  132. or<br> <br> &#8212; the handler for the asynchronous operation is invoked,<br>
  133. <br> whichever comes first. If the total size of all buffers
  134. in the sequence <code class="computeroutput"><span class="identifier">mb</span></code>
  135. is <code class="computeroutput"><span class="number">0</span></code>, the asynchronous
  136. read operation shall complete immediately and pass <code class="computeroutput"><span class="number">0</span></code> as the argument to the handler
  137. that specifies the number of bytes read.<br> <br> If the operation
  138. completes due to graceful connection closure by the peer, the operation
  139. shall fail with <code class="computeroutput"><span class="identifier">error</span><span class="special">::</span><span class="identifier">eof</span></code>.<br>
  140. <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
  141. of bytes transferred. Otherwise it is invoked with <code class="computeroutput"><span class="number">0</span></code>.
  142. </p>
  143. </td>
  144. </tr>
  145. <tr>
  146. <td>
  147. <p>
  148. <code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">send</span><span class="special">(</span><span class="identifier">b</span><span class="special">,</span>
  149. <span class="identifier">cb</span><span class="special">,</span>
  150. <span class="identifier">f</span><span class="special">,</span>
  151. <span class="identifier">ec</span><span class="special">);</span></code>
  152. </p>
  153. </td>
  154. <td>
  155. <p>
  156. <code class="computeroutput"><span class="identifier">size_t</span></code>
  157. </p>
  158. </td>
  159. <td>
  160. <p>
  161. 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>
  162. <br> Writes one or more bytes of data to a connected socket
  163. <code class="computeroutput"><span class="identifier">b</span></code>.<br> <br>
  164. The constant buffer sequence <code class="computeroutput"><span class="identifier">cb</span></code>
  165. specifies memory where the data to be written is located. The operation
  166. shall always write a buffer in the sequence completely before proceeding
  167. to the next.<br> <br> If successful, returns the number of
  168. bytes written. Otherwise returns <code class="computeroutput"><span class="number">0</span></code>.
  169. 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>,
  170. the function shall return <code class="computeroutput"><span class="number">0</span></code>
  171. immediately.
  172. </p>
  173. </td>
  174. </tr>
  175. <tr>
  176. <td>
  177. <p>
  178. <code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">async_send</span><span class="special">(</span><span class="identifier">b</span><span class="special">,</span>
  179. <span class="identifier">cb</span><span class="special">,</span>
  180. <span class="identifier">f</span><span class="special">,</span>
  181. <span class="identifier">wh</span><span class="special">);</span></code>
  182. </p>
  183. </td>
  184. <td>
  185. <p>
  186. <code class="computeroutput"><span class="keyword">void</span></code>
  187. </p>
  188. </td>
  189. <td>
  190. <p>
  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 connected socket <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> &#8212; the last copy
  206. of <code class="computeroutput"><span class="identifier">cb</span></code> is destroyed,
  207. or<br> <br> &#8212; 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>.
  218. </p>
  219. </td>
  220. </tr>
  221. </tbody>
  222. </table></div>
  223. </div>
  224. <br class="table-break">
  225. </div>
  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 &#169; 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>)
  231. </p>
  232. </div></td>
  233. </tr></table>
  234. <hr>
  235. <div class="spirit-nav">
  236. <a accesskey="p" href="StreamHandleService.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="SyncRandomAccessReadDevice.html"><img src="../../next.png" alt="Next"></a>
  237. </div>
  238. </body>
  239. </html>