1[/
2 / Copyright (c) 2003-2016 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:BufferedHandshakeHandler Buffered handshake handler requirements]
9
10A buffered handshake handler must meet the requirements for a [link
11asio.reference.Handler handler]. A value `h` of a buffered handshake handler
12class should work correctly in the expression `h(ec, s)`, where `ec` is an
13lvalue of type `const error_code` and `s` is an lvalue of type `const size_t`.
14
15[heading Examples]
16
17A free function as a buffered handshake handler:
18
19  void handshake_handler(
20      const asio::error_code& ec,
21      std::size_t bytes_transferred)
22  {
23    ...
24  }
25
26A buffered handshake handler function object:
27
28  struct handshake_handler
29  {
30    ...
31    void operator()(
32        const asio::error_code& ec,
33        std::size_t bytes_transferred)
34    {
35      ...
36    }
37    ...
38  };
39
40A non-static class member function adapted to a buffered handshake handler
41using `boost::bind()`:
42
43  void my_class::handshake_handler(
44      const asio::error_code& ec,
45      std::size_t bytes_transferred)
46  {
47    ...
48  }
49  ...
50  socket.async_handshake(...,
51      boost::bind(&my_class::handshake_handler,
52        this, asio::placeholders::error,
53        asio::placeholders::bytes_transferred));
54
55[endsect]
56