ssl.ipp 1.3 KB

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