1[/ 2 / Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com) 3 / 4 / Distributed under the Boost Software License, Version 1.0. (See accompanying 5 / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 /] 7 8[section:HandshakeHandler SSL handshake handler requirements] 9 10A handshake handler must meet the requirements for a [link 11boost_asio.reference.Handler handler]. A value `h` of a handshake handler 12class should work correctly in the expression `h(ec)`, where `ec` is an lvalue 13of type `const error_code`. 14 15[heading Examples] 16 17A free function as a handshake handler: 18 19 void handshake_handler( 20 const boost::system::error_code& ec) 21 { 22 ... 23 } 24 25A handshake handler function object: 26 27 struct handshake_handler 28 { 29 ... 30 void operator()( 31 const boost::system::error_code& ec) 32 { 33 ... 34 } 35 ... 36 }; 37 38A lambda as a handshake handler: 39 40 ssl_stream.async_handshake(..., 41 [](const boost::system::error_code& ec) 42 { 43 ... 44 }); 45 46A non-static class member function adapted to a handshake handler using 47`std::bind()`: 48 49 void my_class::handshake_handler( 50 const boost::system::error_code& ec) 51 { 52 ... 53 } 54 ... 55 ssl_stream.async_handshake(..., 56 std::bind(&my_class::handshake_handler, 57 this, std::placeholders::_1)); 58 59A non-static class member function adapted to a handshake handler using 60`boost::bind()`: 61 62 void my_class::handshake_handler( 63 const boost::system::error_code& ec) 64 { 65 ... 66 } 67 ... 68 ssl_stream.async_handshake(..., 69 boost::bind(&my_class::handshake_handler, 70 this, boost::asio::placeholders::error)); 71 72[endsect] 73