3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>async_detect_ssl</title>
5 <link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7 <link rel="home" href="../../index.html" title="Chapter 1. Boost.Beast">
8 <link rel="up" href="../ref.html" title="This Page Intentionally Left Blank 2/2">
9 <link rel="prev" href="boost__beast__async_base/async_base_dtor_.html" title="async_base::~async_base">
10 <link rel="next" href="boost__beast__async_teardown.html" title="async_teardown">
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr>
14 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
15 <td align="center"><a href="../../../../../../index.html">Home</a></td>
16 <td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
17 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19 <td align="center"><a href="../../../../../../more/index.htm">More</a></td>
22 <div class="spirit-nav">
23 <a accesskey="p" href="boost__beast__async_base/async_base_dtor_.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../ref.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost__beast__async_teardown.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
26 <div class="titlepage"><div><div><h4 class="title">
27 <a name="beast.ref.boost__beast__async_detect_ssl"></a><a class="link" href="boost__beast__async_detect_ssl.html" title="async_detect_ssl">async_detect_ssl</a>
28 </h4></div></div></div>
30 <a class="indexterm" name="idm45873520036896"></a>
31 Detect a TLS/SSL handshake asynchronously on a stream.
34 <a name="beast.ref.boost__beast__async_detect_ssl.h0"></a>
35 <span class="phrase"><a name="beast.ref.boost__beast__async_detect_ssl.synopsis"></a></span><a class="link" href="boost__beast__async_detect_ssl.html#beast.ref.boost__beast__async_detect_ssl.synopsis">Synopsis</a>
38 Defined in header <code class="literal"><<a href="../../../../../../boost/beast/core/detect_ssl.hpp" target="_top">boost/beast/core/detect_ssl.hpp</a>></code>
40 <pre class="programlisting"><span class="keyword">template</span><span class="special"><</span>
41 <span class="keyword">class</span> <a href="../../../../../../doc/html/boost_asio/reference/AsyncReadStream.html" target="_top"><span class="emphasis"><em>AsyncReadStream</em></span></a><span class="special">,</span>
42 <span class="keyword">class</span> <a class="link" href="../concepts/DynamicBuffer.html" title="DynamicBuffer"><span class="emphasis"><em>DynamicBuffer</em></span></a><span class="special">,</span>
43 <span class="keyword">class</span> <a href="../../../../../../doc/html/boost_asio/reference/asynchronous_operations.html#boost_asio.reference.asynchronous_operations.completion_tokens_and_handlers" target="_top"><span class="emphasis"><em>CompletionToken</em></span></a> <span class="special">=</span> <span class="identifier">net</span><span class="special">::</span><span class="identifier">default_completion_token_t</span><span class="special"><</span><span class="identifier">beast</span><span class="special">::</span><span class="identifier">executor_type</span><span class="special"><</span><span class="identifier">AsyncReadStream</span><span class="special">>>></span>
44 <a href="../../../../../../doc/html/boost_asio/reference/asynchronous_operations.html#boost_asio.reference.asynchronous_operations.automatic_deduction_of_initiating_function_return_type" target="_top"><span class="emphasis"><em>DEDUCED</em></span></a>
45 <span class="identifier">async_detect_ssl</span><span class="special">(</span>
46 <span class="identifier">AsyncReadStream</span><span class="special">&</span> <span class="identifier">stream</span><span class="special">,</span>
47 <span class="identifier">DynamicBuffer</span><span class="special">&</span> <span class="identifier">buffer</span><span class="special">,</span>
48 <span class="identifier">CompletionToken</span><span class="special">&&</span> <span class="identifier">token</span> <span class="special">=</span> <span class="identifier">net</span><span class="special">::</span><span class="identifier">default_completion_token_t</span><span class="special"><</span> <span class="identifier">beast</span><span class="special">::</span><span class="identifier">executor_type</span><span class="special"><</span> <span class="identifier">AsyncReadStream</span> <span class="special">>>{});</span>
51 <a name="beast.ref.boost__beast__async_detect_ssl.h1"></a>
52 <span class="phrase"><a name="beast.ref.boost__beast__async_detect_ssl.description"></a></span><a class="link" href="boost__beast__async_detect_ssl.html#beast.ref.boost__beast__async_detect_ssl.description">Description</a>
55 This function reads asynchronously from a stream to determine if a client
56 handshake message is being received. This call always returns immediately.
57 The asynchronous operation will continue until one of the following conditions
60 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
62 A TLS client opening handshake is detected,
65 The received data is invalid for a TLS client handshake, or
72 The algorithm, known as a <span class="emphasis"><em>composed asynchronous operation</em></span>,
73 is implemented in terms of calls to the next layer's <code class="computeroutput"><span class="identifier">async_read_some</span></code>
74 function. The program must ensure that no other calls to <code class="computeroutput"><span class="identifier">async_read_some</span></code>
75 are performed until this operation completes. Bytes read from the stream
76 will be stored in the passed dynamic buffer, which may be used to perform
77 the TLS handshake if the detector returns true, or be otherwise consumed
78 by the caller based on the expected protocol.
81 <a name="beast.ref.boost__beast__async_detect_ssl.h2"></a>
82 <span class="phrase"><a name="beast.ref.boost__beast__async_detect_ssl.parameters"></a></span><a class="link" href="boost__beast__async_detect_ssl.html#beast.ref.boost__beast__async_detect_ssl.parameters">Parameters</a>
84 <div class="informaltable"><table class="table">
105 <code class="computeroutput"><span class="identifier">stream</span></code>
110 The stream to read from. This type must meet the requirements of
111 <span class="emphasis"><em>AsyncReadStream</em></span>.
118 <code class="computeroutput"><span class="identifier">buffer</span></code>
123 The dynamic buffer to use. This type must meet the requirements
124 of <span class="emphasis"><em>DynamicBuffer</em></span>.
131 <code class="computeroutput"><span class="identifier">token</span></code>
136 The completion token used to determine the method used to provide
137 the result of the asynchronous operation. If this is a completion
138 handler, the implementation takes ownership of the handler by performing
139 a decay-copy, and the equivalent function signature of the handler
142 <pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="keyword">void</span> <span class="identifier">handler</span><span class="special">(</span>
143 <span class="identifier">error_code</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">error</span><span class="special">,</span> <span class="comment">// Set to the error, if any</span>
144 <span class="keyword">bool</span> <span class="identifier">result</span> <span class="comment">// The result of the detector</span>
145 <span class="special">);</span>
148 Regardless of whether the asynchronous operation completes immediately
149 or not, the handler will not be invoked from within this function.
150 Invocation of the handler will be performed in a manner equivalent
151 to using <code class="computeroutput"><span class="identifier">net</span><span class="special">::</span><span class="identifier">post</span></code>.
158 Convenience header <code class="literal"><<a href="../../../../../../boost/beast/core.hpp" target="_top">boost/beast/core.hpp</a>></code>
161 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
162 <td align="left"></td>
163 <td align="right"><div class="copyright-footer">Copyright © 2016-2019 Vinnie
165 Distributed under the Boost Software License, Version 1.0. (See accompanying
166 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
171 <div class="spirit-nav">
172 <a accesskey="p" href="boost__beast__async_base/async_base_dtor_.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../ref.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost__beast__async_teardown.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>