1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>SSL handshake handler requirements</title> 5<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.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="Handler.html" title="Handlers"> 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> 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> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="Handler.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="InternetProtocol.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h3 class="title"> 27<a name="boost_asio.reference.HandshakeHandler"></a><a class="link" href="HandshakeHandler.html" title="SSL handshake handler requirements">SSL handshake 28 handler requirements</a> 29</h3></div></div></div> 30<p> 31 A handshake handler must meet the requirements for a <a class="link" href="Handler.html" title="Handlers">handler</a>. 32 A value <code class="computeroutput">h</code> of a handshake handler class should work correctly 33 in the expression <code class="computeroutput">h(ec)</code>, where <code class="computeroutput">ec</code> is an lvalue 34 of type <code class="computeroutput">const error_code</code>. 35 </p> 36<h5> 37<a name="boost_asio.reference.HandshakeHandler.h0"></a> 38 <span class="phrase"><a name="boost_asio.reference.HandshakeHandler.examples"></a></span><a class="link" href="HandshakeHandler.html#boost_asio.reference.HandshakeHandler.examples">Examples</a> 39 </h5> 40<p> 41 A free function as a handshake handler: 42 </p> 43<pre class="programlisting">void handshake_handler( 44 const boost::system::error_code& ec) 45{ 46 ... 47} 48</pre> 49<p> 50 A handshake handler function object: 51 </p> 52<pre class="programlisting">struct handshake_handler 53{ 54 ... 55 void operator()( 56 const boost::system::error_code& ec) 57 { 58 ... 59 } 60 ... 61}; 62</pre> 63<p> 64 A lambda as a handshake handler: 65 </p> 66<pre class="programlisting">ssl_stream.async_handshake(..., 67 [](const boost::system::error_code& ec) 68 { 69 ... 70 }); 71</pre> 72<p> 73 A non-static class member function adapted to a handshake handler using 74 <code class="computeroutput">std::bind()</code>: 75 </p> 76<pre class="programlisting">void my_class::handshake_handler( 77 const boost::system::error_code& ec) 78{ 79 ... 80} 81... 82ssl_stream.async_handshake(..., 83 std::bind(&my_class::handshake_handler, 84 this, std::placeholders::_1)); 85</pre> 86<p> 87 A non-static class member function adapted to a handshake handler using 88 <code class="computeroutput">boost::bind()</code>: 89 </p> 90<pre class="programlisting">void my_class::handshake_handler( 91 const boost::system::error_code& ec) 92{ 93 ... 94} 95... 96ssl_stream.async_handshake(..., 97 boost::bind(&my_class::handshake_handler, 98 this, boost::asio::placeholders::error)); 99</pre> 100</div> 101<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 102<td align="left"></td> 103<td align="right"><div class="copyright-footer">Copyright © 2003-2020 Christopher M. 104 Kohlhoff<p> 105 Distributed under the Boost Software License, Version 1.0. (See accompanying 106 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>) 107 </p> 108</div></td> 109</tr></table> 110<hr> 111<div class="spirit-nav"> 112<a accesskey="p" href="Handler.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="InternetProtocol.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 113</div> 114</body> 115</html> 116