HandshakeHandler.html 6.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  4. <title>SSL handshake handler 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="HandleService.html" title="Handle service requirements">
  10. <link rel="next" href="InternetProtocol.html" title="Internet protocol 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="HandleService.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="InternetProtocol.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.HandshakeHandler"></a><a class="link" href="HandshakeHandler.html" title="SSL handshake handler requirements">SSL handshake handler
  21. requirements</a>
  22. </h3></div></div></div>
  23. <p>
  24. A handshake handler must meet the requirements for a <a class="link" href="Handler.html" title="Handlers">handler</a>.
  25. A value <code class="computeroutput"><span class="identifier">h</span></code> of a handshake
  26. handler class should work correctly in the expression <code class="computeroutput"><span class="identifier">h</span><span class="special">(</span><span class="identifier">ec</span><span class="special">)</span></code>,
  27. where <code class="computeroutput"><span class="identifier">ec</span></code> is an lvalue of
  28. type <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">error_code</span></code>.
  29. </p>
  30. <h5>
  31. <a name="asio.reference.HandshakeHandler.h0"></a>
  32. <span><a name="asio.reference.HandshakeHandler.examples"></a></span><a class="link" href="HandshakeHandler.html#asio.reference.HandshakeHandler.examples">Examples</a>
  33. </h5>
  34. <p>
  35. A free function as a handshake handler:
  36. </p>
  37. <pre class="programlisting"><span class="keyword">void</span> <span class="identifier">handshake_handler</span><span class="special">(</span>
  38. <span class="keyword">const</span> <span class="identifier">asio</span><span class="special">::</span><span class="identifier">error_code</span><span class="special">&amp;</span> <span class="identifier">ec</span><span class="special">)</span>
  39. <span class="special">{</span>
  40. <span class="special">...</span>
  41. <span class="special">}</span>
  42. </pre>
  43. <p>
  44. A handshake handler function object:
  45. </p>
  46. <pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">handshake_handler</span>
  47. <span class="special">{</span>
  48. <span class="special">...</span>
  49. <span class="keyword">void</span> <span class="keyword">operator</span><span class="special">()(</span>
  50. <span class="keyword">const</span> <span class="identifier">asio</span><span class="special">::</span><span class="identifier">error_code</span><span class="special">&amp;</span> <span class="identifier">ec</span><span class="special">)</span>
  51. <span class="special">{</span>
  52. <span class="special">...</span>
  53. <span class="special">}</span>
  54. <span class="special">...</span>
  55. <span class="special">};</span>
  56. </pre>
  57. <p>
  58. A non-static class member function adapted to a handshake handler using
  59. <code class="computeroutput"><span class="identifier">bind</span><span class="special">()</span></code>:
  60. </p>
  61. <pre class="programlisting"><span class="keyword">void</span> <span class="identifier">my_class</span><span class="special">::</span><span class="identifier">handshake_handler</span><span class="special">(</span>
  62. <span class="keyword">const</span> <span class="identifier">asio</span><span class="special">::</span><span class="identifier">error_code</span><span class="special">&amp;</span> <span class="identifier">ec</span><span class="special">)</span>
  63. <span class="special">{</span>
  64. <span class="special">...</span>
  65. <span class="special">}</span>
  66. <span class="special">...</span>
  67. <span class="identifier">ssl_stream</span><span class="special">.</span><span class="identifier">async_handshake</span><span class="special">(...,</span>
  68. <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(&amp;</span><span class="identifier">my_class</span><span class="special">::</span><span class="identifier">handshake_handler</span><span class="special">,</span>
  69. <span class="keyword">this</span><span class="special">,</span> <span class="identifier">asio</span><span class="special">::</span><span class="identifier">placeholders</span><span class="special">::</span><span class="identifier">error</span><span class="special">));</span>
  70. </pre>
  71. </div>
  72. <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
  73. <td align="left"></td>
  74. <td align="right"><div class="copyright-footer">Copyright &#169; 2003-2014 Christopher M. Kohlhoff<p>
  75. Distributed under the Boost Software License, Version 1.0. (See accompanying
  76. 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>)
  77. </p>
  78. </div></td>
  79. </tr></table>
  80. <hr>
  81. <div class="spirit-nav">
  82. <a accesskey="p" href="HandleService.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="InternetProtocol.html"><img src="../../next.png" alt="Next"></a>
  83. </div>
  84. </body>
  85. </html>