BufferedHandshakeHandler.qbk 1.4 KB

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