1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 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__detect_ssl.html" title="detect_ssl"> 10<link rel="next" href="boost__beast__generic_category.html" title="generic_category"> 11</head> 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> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="boost__beast__detect_ssl.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__generic_category.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 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> 29<p> 30 <a class="indexterm" name="idm46057512877712"></a> 31 </p> 32<p> 33 Detect a TLS/SSL handshake asynchronously on a stream. 34 </p> 35<h5> 36<a name="beast.ref.boost__beast__async_detect_ssl.h0"></a> 37 <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 </h5> 39<p> 40 Defined in header <code class="literal"><<a href="../../../../../../boost/beast/core/detect_ssl.hpp" target="_top">boost/beast/core/detect_ssl.hpp</a>></code> 41 </p> 42<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> 43 <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> 44 <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> 45 <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> 46<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> 47<span class="identifier">async_detect_ssl</span><span class="special">(</span> 48 <span class="identifier">AsyncReadStream</span><span class="special">&</span> <span class="identifier">stream</span><span class="special">,</span> 49 <span class="identifier">DynamicBuffer</span><span class="special">&</span> <span class="identifier">buffer</span><span class="special">,</span> 50 <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> <a class="link" href="boost__beast__executor_type.html" title="executor_type">beast::executor_type</a><span class="special"><</span> <span class="identifier">AsyncReadStream</span> <span class="special">>>{});</span> 51</pre> 52<h5> 53<a name="beast.ref.boost__beast__async_detect_ssl.h1"></a> 54 <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 </h5> 56<p> 57 This function reads asynchronously from a stream to determine if a client 58 handshake message is being received. This call always returns immediately. 59 The asynchronous operation will continue until one of the following conditions 60 is true: 61 </p> 62<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 63<li class="listitem"> 64 A TLS client opening handshake is detected, 65 </li> 66<li class="listitem"> 67 The received data is invalid for a TLS client handshake, or 68 </li> 69<li class="listitem"> 70 An error occurs. 71 </li> 72</ul></div> 73<p> 74 The algorithm, known as a <span class="emphasis"><em>composed asynchronous operation</em></span>, 75 is implemented in terms of calls to the next layer's <code class="computeroutput"><span class="identifier">async_read_some</span></code> 76 function. The program must ensure that no other calls to <code class="computeroutput"><span class="identifier">async_read_some</span></code> 77 are performed until this operation completes. Bytes read from the stream 78 will be stored in the passed dynamic buffer, which may be used to perform 79 the TLS handshake if the detector returns true, or be otherwise consumed 80 by the caller based on the expected protocol. 81 </p> 82<h5> 83<a name="beast.ref.boost__beast__async_detect_ssl.h2"></a> 84 <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> 85 </h5> 86<div class="informaltable"><table class="table"> 87<colgroup> 88<col> 89<col> 90</colgroup> 91<thead><tr> 92<th> 93 <p> 94 Name 95 </p> 96 </th> 97<th> 98 <p> 99 Description 100 </p> 101 </th> 102</tr></thead> 103<tbody> 104<tr> 105<td> 106 <p> 107 <code class="computeroutput"><span class="identifier">stream</span></code> 108 </p> 109 </td> 110<td> 111 <p> 112 The stream to read from. This type must meet the requirements of 113 <span class="emphasis"><em>AsyncReadStream</em></span>. 114 </p> 115 </td> 116</tr> 117<tr> 118<td> 119 <p> 120 <code class="computeroutput"><span class="identifier">buffer</span></code> 121 </p> 122 </td> 123<td> 124 <p> 125 The dynamic buffer to use. This type must meet the requirements 126 of <span class="emphasis"><em>DynamicBuffer</em></span>. 127 </p> 128 </td> 129</tr> 130<tr> 131<td> 132 <p> 133 <code class="computeroutput"><span class="identifier">token</span></code> 134 </p> 135 </td> 136<td> 137 <p> 138 The completion token used to determine the method used to provide 139 the result of the asynchronous operation. If this is a completion 140 handler, the implementation takes ownership of the handler by performing 141 a decay-copy, and the equivalent function signature of the handler 142 must be: 143 </p> 144<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> 145 <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> 146 <span class="keyword">bool</span> <span class="identifier">result</span> <span class="comment">// The result of the detector</span> 147<span class="special">);</span> 148</pre> 149 <p> 150 Regardless of whether the asynchronous operation completes immediately 151 or not, the handler will not be invoked from within this function. 152 Invocation of the handler will be performed in a manner equivalent 153 to using <code class="computeroutput"><span class="identifier">net</span><span class="special">::</span><span class="identifier">post</span></code>. 154 </p> 155 </td> 156</tr> 157</tbody> 158</table></div> 159</div> 160<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 161<td align="left"></td> 162<td align="right"><div class="copyright-footer">Copyright © 2016-2019 Vinnie 163 Falco<p> 164 Distributed under the Boost Software License, Version 1.0. (See accompanying 165 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>) 166 </p> 167</div></td> 168</tr></table> 169<hr> 170<div class="spirit-nav"> 171<a accesskey="p" href="boost__beast__detect_ssl.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__generic_category.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 172</div> 173</body> 174</html> 175