ssl.hpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail 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. // Official repository: https://github.com/boostorg/beast
  8. //
  9. #ifndef BOOST_BEAST_WEBSOCKET_IMPL_SSL_HPP
  10. #define BOOST_BEAST_WEBSOCKET_IMPL_SSL_HPP
  11. #include <utility>
  12. namespace boost {
  13. namespace beast {
  14. /*
  15. See
  16. http://stackoverflow.com/questions/32046034/what-is-the-proper-way-to-securely-disconnect-an-asio-ssl-socket/32054476#32054476
  17. Behavior of ssl::stream regarding close_notify
  18. If the remote host calls async_shutdown then the
  19. local host's async_read will complete with eof.
  20. If both hosts call async_shutdown then the calls
  21. to async_shutdown will complete with eof.
  22. */
  23. template<class AsyncStream>
  24. void
  25. teardown(
  26. role_type,
  27. net::ssl::stream<AsyncStream>& stream,
  28. error_code& ec)
  29. {
  30. stream.shutdown(ec);
  31. }
  32. template<
  33. class AsyncStream,
  34. class TeardownHandler>
  35. void
  36. async_teardown(
  37. role_type,
  38. net::ssl::stream<AsyncStream>& stream,
  39. TeardownHandler&& handler)
  40. {
  41. stream.async_shutdown(
  42. std::forward<TeardownHandler>(handler));
  43. }
  44. } // beast
  45. } // boost
  46. #endif