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