RawSocketService.html 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  4. <title>Raw 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="RandomAccessHandleService.html" title="Random access handle service requirements">
  10. <link rel="next" href="ReadHandler.html" title="Read handler 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="RandomAccessHandleService.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="ReadHandler.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.RawSocketService"></a><a class="link" href="RawSocketService.html" title="Raw socket service requirements">Raw socket service requirements</a>
  21. </h3></div></div></div>
  22. <p>
  23. A raw socket service must meet the requirements for a <a class="link" href="SocketService.html" title="Socket service requirements">socket
  24. service</a>, as well as the additional requirements listed below.
  25. </p>
  26. <p>
  27. In the table below, <code class="computeroutput"><span class="identifier">X</span></code> denotes
  28. a raw socket service class for protocol <a class="link" href="Protocol.html" title="Protocol requirements"><code class="computeroutput"><span class="identifier">Protocol</span></code></a>, <code class="computeroutput"><span class="identifier">a</span></code>
  29. denotes a value of type <code class="computeroutput"><span class="identifier">X</span></code>,
  30. <code class="computeroutput"><span class="identifier">b</span></code> denotes a value of type
  31. <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">e</span></code>
  32. denotes a value of type <code class="computeroutput"><span class="identifier">Protocol</span><span class="special">::</span><span class="identifier">endpoint</span></code>,
  33. <code class="computeroutput"><span class="identifier">ec</span></code> denotes a value of type
  34. <code class="computeroutput"><span class="identifier">error_code</span></code>, <code class="computeroutput"><span class="identifier">f</span></code> denotes a value of type <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>
  35. denotes a value satisfying <a class="link" href="MutableBufferSequence.html" title="Mutable buffer sequence requirements">mutable
  36. buffer sequence</a> requirements, <code class="computeroutput"><span class="identifier">rh</span></code>
  37. 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
  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.RawSocketService.t0"></a><p class="title"><b>Table&#160;22.&#160;RawSocketService requirements</b></p>
  43. <div class="table-contents"><table class="table" summary="RawSocketService 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">receive</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">f</span><span class="special">,</span>
  73. <span class="identifier">ec</span><span class="special">);</span></code>
  74. </p>
  75. </td>
  76. <td>
  77. <p>
  78. <code class="computeroutput"><span class="identifier">size_t</span></code>
  79. </p>
  80. </td>
  81. <td>
  82. <p>
  83. 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>
  84. <br> Reads one or more bytes of data from a connected socket
  85. <code class="computeroutput"><span class="identifier">b</span></code>.<br> <br>
  86. The mutable buffer sequence <code class="computeroutput"><span class="identifier">mb</span></code>
  87. specifies memory where the data should be placed. The operation
  88. shall always fill a buffer in the sequence completely before proceeding
  89. to the next.<br> <br> If successful, returns the number of
  90. bytes read. Otherwise returns <code class="computeroutput"><span class="number">0</span></code>.
  91. </p>
  92. </td>
  93. </tr>
  94. <tr>
  95. <td>
  96. <p>
  97. <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>
  98. <span class="identifier">mb</span><span class="special">,</span>
  99. <span class="identifier">f</span><span class="special">,</span>
  100. <span class="identifier">rh</span><span class="special">);</span></code>
  101. </p>
  102. </td>
  103. <td>
  104. <p>
  105. <code class="computeroutput"><span class="keyword">void</span></code>
  106. </p>
  107. </td>
  108. <td>
  109. <p>
  110. 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>
  111. <br> Initiates an asynchronous operation to read one or more
  112. bytes of data from a connected socket <code class="computeroutput"><span class="identifier">b</span></code>.
  113. The operation is performed via the <code class="computeroutput"><span class="identifier">io_service</span></code>
  114. 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>
  115. and behaves according to <a class="link" href="asynchronous_operations.html" title="Requirements on asynchronous operations">asynchronous
  116. operation</a> requirements.<br> <br> The mutable buffer
  117. sequence <code class="computeroutput"><span class="identifier">mb</span></code> specifies
  118. memory where the data should be placed. The operation shall always
  119. fill a buffer in the sequence completely before proceeding to the
  120. next.<br> <br> The implementation shall maintain one or more
  121. copies of <code class="computeroutput"><span class="identifier">mb</span></code> until
  122. such time as the read operation no longer requires access to the
  123. memory specified by the buffers in the sequence. The program must
  124. ensure the memory is valid until:<br> <br> &#8212; the last copy of
  125. <code class="computeroutput"><span class="identifier">mb</span></code> is destroyed,
  126. or<br> <br> &#8212; the handler for the asynchronous operation is invoked,<br>
  127. <br> whichever comes first.<br> <br> If the operation completes
  128. successfully, the <code class="computeroutput"><span class="identifier">ReadHandler</span></code>
  129. object <code class="computeroutput"><span class="identifier">rh</span></code> is invoked
  130. with the number of bytes transferred. Otherwise it is invoked with
  131. <code class="computeroutput"><span class="number">0</span></code>.
  132. </p>
  133. </td>
  134. </tr>
  135. <tr>
  136. <td>
  137. <p>
  138. <code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">receive_from</span><span class="special">(</span><span class="identifier">b</span><span class="special">,</span>
  139. <span class="identifier">mb</span><span class="special">,</span>
  140. <span class="identifier">e</span><span class="special">,</span>
  141. <span class="identifier">f</span><span class="special">,</span>
  142. <span class="identifier">ec</span><span class="special">);</span></code>
  143. </p>
  144. </td>
  145. <td>
  146. <p>
  147. <code class="computeroutput"><span class="identifier">size_t</span></code>
  148. </p>
  149. </td>
  150. <td>
  151. <p>
  152. 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>
  153. <br> Reads one or more bytes of data from an unconnected socket
  154. <code class="computeroutput"><span class="identifier">b</span></code>.<br> <br>
  155. The mutable buffer sequence <code class="computeroutput"><span class="identifier">mb</span></code>
  156. specifies memory where the data should be placed. The operation
  157. shall always fill a buffer in the sequence completely before proceeding
  158. to the next.<br> <br> If successful, returns the number of
  159. bytes read. Otherwise returns <code class="computeroutput"><span class="number">0</span></code>.
  160. </p>
  161. </td>
  162. </tr>
  163. <tr>
  164. <td>
  165. <p>
  166. <code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">async_receive_from</span><span class="special">(</span><span class="identifier">b</span><span class="special">,</span>
  167. <span class="identifier">mb</span><span class="special">,</span>
  168. <span class="identifier">e</span><span class="special">,</span>
  169. <span class="identifier">f</span><span class="special">,</span>
  170. <span class="identifier">rh</span><span class="special">);</span></code>
  171. </p>
  172. </td>
  173. <td>
  174. <p>
  175. <code class="computeroutput"><span class="keyword">void</span></code>
  176. </p>
  177. </td>
  178. <td>
  179. <p>
  180. 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>
  181. <br> Initiates an asynchronous operation to read one or more
  182. bytes of data from an unconnected socket <code class="computeroutput"><span class="identifier">b</span></code>.
  183. The operation is performed via the <code class="computeroutput"><span class="identifier">io_service</span></code>
  184. 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>
  185. and behaves according to <a class="link" href="asynchronous_operations.html" title="Requirements on asynchronous operations">asynchronous
  186. operation</a> requirements.<br> <br> The mutable buffer
  187. sequence <code class="computeroutput"><span class="identifier">mb</span></code> specifies
  188. memory where the data should be placed. The operation shall always
  189. fill a buffer in the sequence completely before proceeding to the
  190. next.<br> <br> The implementation shall maintain one or more
  191. copies of <code class="computeroutput"><span class="identifier">mb</span></code> until
  192. such time as the read operation no longer requires access to the
  193. memory specified by the buffers in the sequence. The program must
  194. ensure the memory is valid until:<br> <br> &#8212; the last copy of
  195. <code class="computeroutput"><span class="identifier">mb</span></code> is destroyed,
  196. or<br> <br> &#8212; the handler for the asynchronous operation is invoked,<br>
  197. <br> whichever comes first.<br> <br> The program must ensure
  198. the object <code class="computeroutput"><span class="identifier">e</span></code> is
  199. valid until the handler for the asynchronous operation is invoked.<br>
  200. <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
  201. of bytes transferred. Otherwise it is invoked with <code class="computeroutput"><span class="number">0</span></code>.
  202. </p>
  203. </td>
  204. </tr>
  205. <tr>
  206. <td>
  207. <p>
  208. <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>
  209. <span class="identifier">cb</span><span class="special">,</span>
  210. <span class="identifier">f</span><span class="special">,</span>
  211. <span class="identifier">ec</span><span class="special">);</span></code>
  212. </p>
  213. </td>
  214. <td>
  215. <p>
  216. <code class="computeroutput"><span class="identifier">size_t</span></code>
  217. </p>
  218. </td>
  219. <td>
  220. <p>
  221. 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>
  222. <br> Writes one or more bytes of data to a connected socket
  223. <code class="computeroutput"><span class="identifier">b</span></code>.<br> <br>
  224. The constant buffer sequence <code class="computeroutput"><span class="identifier">cb</span></code>
  225. specifies memory where the data to be written is located. The operation
  226. shall always write a buffer in the sequence completely before proceeding
  227. to the next.<br> <br> If successful, returns the number of
  228. bytes written. Otherwise returns <code class="computeroutput"><span class="number">0</span></code>.
  229. </p>
  230. </td>
  231. </tr>
  232. <tr>
  233. <td>
  234. <p>
  235. <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>
  236. <span class="identifier">cb</span><span class="special">,</span>
  237. <span class="identifier">f</span><span class="special">,</span>
  238. <span class="identifier">wh</span><span class="special">);</span></code>
  239. </p>
  240. </td>
  241. <td>
  242. <p>
  243. <code class="computeroutput"><span class="keyword">void</span></code>
  244. </p>
  245. </td>
  246. <td>
  247. <p>
  248. 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>
  249. <br> Initiates an asynchronous operation to write one or more
  250. bytes of data to a connected socket <code class="computeroutput"><span class="identifier">b</span></code>.
  251. The operation is performed via the <code class="computeroutput"><span class="identifier">io_service</span></code>
  252. 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>
  253. and behaves according to <a class="link" href="asynchronous_operations.html" title="Requirements on asynchronous operations">asynchronous
  254. operation</a> requirements.<br> <br> The constant buffer
  255. sequence <code class="computeroutput"><span class="identifier">cb</span></code> specifies
  256. memory where the data to be written is located. The operation shall
  257. always write a buffer in the sequence completely before proceeding
  258. to the next.<br> <br> The implementation shall maintain one
  259. or more copies of <code class="computeroutput"><span class="identifier">cb</span></code>
  260. until such time as the write operation no longer requires access
  261. to the memory specified by the buffers in the sequence. The program
  262. must ensure the memory is valid until:<br> <br> &#8212; the last copy
  263. of <code class="computeroutput"><span class="identifier">cb</span></code> is destroyed,
  264. or<br> <br> &#8212; the handler for the asynchronous operation is invoked,<br>
  265. <br> whichever comes first.<br> <br> If the operation completes
  266. successfully, the <code class="computeroutput"><span class="identifier">WriteHandler</span></code>
  267. object <code class="computeroutput"><span class="identifier">wh</span></code> is invoked
  268. with the number of bytes transferred. Otherwise it is invoked with
  269. <code class="computeroutput"><span class="number">0</span></code>.
  270. </p>
  271. </td>
  272. </tr>
  273. <tr>
  274. <td>
  275. <p>
  276. </p>
  277. <pre class="programlisting"><span class="keyword">const</span> <span class="keyword">typename</span> <span class="identifier">Protocol</span><span class="special">::</span><span class="identifier">endpoint</span><span class="special">&amp;</span> <span class="identifier">u</span> <span class="special">=</span> <span class="identifier">e</span><span class="special">;</span>
  278. <span class="identifier">a</span><span class="special">.</span><span class="identifier">send_to</span><span class="special">(</span><span class="identifier">b</span><span class="special">,</span> <span class="identifier">cb</span><span class="special">,</span> <span class="identifier">u</span><span class="special">,</span> <span class="identifier">f</span><span class="special">,</span> <span class="identifier">ec</span><span class="special">);</span>
  279. </pre>
  280. <p>
  281. </p>
  282. </td>
  283. <td>
  284. <p>
  285. <code class="computeroutput"><span class="identifier">size_t</span></code>
  286. </p>
  287. </td>
  288. <td>
  289. <p>
  290. 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>
  291. <br> Writes one or more bytes of data to an unconnected socket
  292. <code class="computeroutput"><span class="identifier">b</span></code>.<br> <br>
  293. The constant buffer sequence <code class="computeroutput"><span class="identifier">cb</span></code>
  294. specifies memory where the data to be written is located. The operation
  295. shall always write a buffer in the sequence completely before proceeding
  296. to the next.<br> <br> If successful, returns the number of
  297. bytes written. Otherwise returns <code class="computeroutput"><span class="number">0</span></code>.
  298. </p>
  299. </td>
  300. </tr>
  301. <tr>
  302. <td>
  303. <p>
  304. </p>
  305. <pre class="programlisting"><span class="keyword">const</span> <span class="keyword">typename</span> <span class="identifier">Protocol</span><span class="special">::</span><span class="identifier">endpoint</span><span class="special">&amp;</span> <span class="identifier">u</span> <span class="special">=</span> <span class="identifier">e</span><span class="special">;</span>
  306. <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> <span class="identifier">cb</span><span class="special">,</span> <span class="identifier">u</span><span class="special">,</span> <span class="identifier">f</span><span class="special">,</span> <span class="identifier">wh</span><span class="special">);</span>
  307. </pre>
  308. <p>
  309. </p>
  310. </td>
  311. <td>
  312. <p>
  313. <code class="computeroutput"><span class="keyword">void</span></code>
  314. </p>
  315. </td>
  316. <td>
  317. <p>
  318. 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>
  319. <br> Initiates an asynchronous operation to write one or more
  320. bytes of data to an unconnected socket <code class="computeroutput"><span class="identifier">b</span></code>.
  321. The operation is performed via the <code class="computeroutput"><span class="identifier">io_service</span></code>
  322. 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>
  323. and behaves according to <a class="link" href="asynchronous_operations.html" title="Requirements on asynchronous operations">asynchronous
  324. operation</a> requirements.<br> <br> The constant buffer
  325. sequence <code class="computeroutput"><span class="identifier">cb</span></code> specifies
  326. memory where the data to be written is located. The operation shall
  327. always write a buffer in the sequence completely before proceeding
  328. to the next.<br> <br> The implementation shall maintain one
  329. or more copies of <code class="computeroutput"><span class="identifier">cb</span></code>
  330. until such time as the write operation no longer requires access
  331. to the memory specified by the buffers in the sequence. The program
  332. must ensure the memory is valid until:<br> <br> &#8212; the last copy
  333. of <code class="computeroutput"><span class="identifier">cb</span></code> is destroyed,
  334. or<br> <br> &#8212; the handler for the asynchronous operation is invoked,<br>
  335. <br> whichever comes first.<br> <br> If the operation completes
  336. successfully, the <code class="computeroutput"><span class="identifier">WriteHandler</span></code>
  337. object <code class="computeroutput"><span class="identifier">wh</span></code> is invoked
  338. with the number of bytes transferred. Otherwise it is invoked with
  339. <code class="computeroutput"><span class="number">0</span></code>.
  340. </p>
  341. </td>
  342. </tr>
  343. </tbody>
  344. </table></div>
  345. </div>
  346. <br class="table-break">
  347. </div>
  348. <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
  349. <td align="left"></td>
  350. <td align="right"><div class="copyright-footer">Copyright &#169; 2003-2014 Christopher M. Kohlhoff<p>
  351. Distributed under the Boost Software License, Version 1.0. (See accompanying
  352. 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>)
  353. </p>
  354. </div></td>
  355. </tr></table>
  356. <hr>
  357. <div class="spirit-nav">
  358. <a accesskey="p" href="RandomAccessHandleService.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="ReadHandler.html"><img src="../../next.png" alt="Next"></a>
  359. </div>
  360. </body>
  361. </html>