• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>basic_stream::rebind_executor::other</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="../boost__beast__basic_stream__rebind_executor.html" title="basic_stream::rebind_executor">
9<link rel="prev" href="../boost__beast__basic_stream__rebind_executor.html" title="basic_stream::rebind_executor">
10<link rel="next" href="../boost__beast__saved_handler.html" title="saved_handler">
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__basic_stream__rebind_executor.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../boost__beast__basic_stream__rebind_executor.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__saved_handler.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h5 class="title">
27<a name="beast.ref.boost__beast__basic_stream__rebind_executor.other"></a><a class="link" href="other.html" title="basic_stream::rebind_executor::other">basic_stream::rebind_executor::other</a>
28</h5></div></div></div>
29<p>
30          <a class="indexterm" name="idm46057529734704"></a>
31        </p>
32<p>
33          The stream type when rebound to the specified executor.
34        </p>
35<h6>
36<a name="beast.ref.boost__beast__basic_stream__rebind_executor.other.h0"></a>
37          <span class="phrase"><a name="beast.ref.boost__beast__basic_stream__rebind_executor.other.synopsis"></a></span><a class="link" href="other.html#beast.ref.boost__beast__basic_stream__rebind_executor.other.synopsis">Synopsis</a>
38        </h6>
39<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">other</span> <span class="special">=</span> <span class="identifier">basic_stream</span><span class="special">&lt;</span> <span class="identifier">Protocol</span><span class="special">,</span> <span class="identifier">Executor1</span><span class="special">,</span> <span class="identifier">RatePolicy</span> <span class="special">&gt;;</span>
40</pre>
41<h6>
42<a name="beast.ref.boost__beast__basic_stream__rebind_executor.other.h1"></a>
43          <span class="phrase"><a name="beast.ref.boost__beast__basic_stream__rebind_executor.other.types"></a></span><a class="link" href="other.html#beast.ref.boost__beast__basic_stream__rebind_executor.other.types">Types</a>
44        </h6>
45<div class="informaltable"><table class="table">
46<colgroup>
47<col>
48<col>
49</colgroup>
50<thead><tr>
51<th>
52                  <p>
53                    Name
54                  </p>
55                </th>
56<th>
57                  <p>
58                    Description
59                  </p>
60                </th>
61</tr></thead>
62<tbody>
63<tr>
64<td>
65                  <p>
66                    <span class="bold"><strong><a class="link" href="../boost__beast__basic_stream/endpoint_type.html" title="basic_stream::endpoint_type">endpoint_type</a></strong></span>
67                  </p>
68                </td>
69<td>
70                  <p>
71                    The endpoint type.
72                  </p>
73                </td>
74</tr>
75<tr>
76<td>
77                  <p>
78                    <span class="bold"><strong><a class="link" href="../boost__beast__basic_stream/executor_type.html" title="basic_stream::executor_type">executor_type</a></strong></span>
79                  </p>
80                </td>
81<td>
82                  <p>
83                    The type of the executor associated with the stream.
84                  </p>
85                </td>
86</tr>
87<tr>
88<td>
89                  <p>
90                    <span class="bold"><strong><a class="link" href="../boost__beast__basic_stream/protocol_type.html" title="basic_stream::protocol_type">protocol_type</a></strong></span>
91                  </p>
92                </td>
93<td>
94                  <p>
95                    The protocol type.
96                  </p>
97                </td>
98</tr>
99<tr>
100<td>
101                  <p>
102                    <span class="bold"><strong><a class="link" href="../boost__beast__basic_stream__rebind_executor.html" title="basic_stream::rebind_executor">rebind_executor</a></strong></span>
103                  </p>
104                </td>
105<td>
106                  <p>
107                    Rebinds the stream type to another executor.
108                  </p>
109                </td>
110</tr>
111<tr>
112<td>
113                  <p>
114                    <span class="bold"><strong><a class="link" href="../boost__beast__basic_stream/socket_type.html" title="basic_stream::socket_type">socket_type</a></strong></span>
115                  </p>
116                </td>
117<td>
118                  <p>
119                    The type of the underlying socket.
120                  </p>
121                </td>
122</tr>
123</tbody>
124</table></div>
125<h6>
126<a name="beast.ref.boost__beast__basic_stream__rebind_executor.other.h2"></a>
127          <span class="phrase"><a name="beast.ref.boost__beast__basic_stream__rebind_executor.other.member_functions"></a></span><a class="link" href="other.html#beast.ref.boost__beast__basic_stream__rebind_executor.other.member_functions">Member
128          Functions</a>
129        </h6>
130<div class="informaltable"><table class="table">
131<colgroup>
132<col>
133<col>
134</colgroup>
135<thead><tr>
136<th>
137                  <p>
138                    Name
139                  </p>
140                </th>
141<th>
142                  <p>
143                    Description
144                  </p>
145                </th>
146</tr></thead>
147<tbody>
148<tr>
149<td>
150                  <p>
151                    <span class="bold"><strong><a class="link" href="../boost__beast__basic_stream/async_connect.html" title="basic_stream::async_connect">async_connect</a></strong></span>
152                  </p>
153                </td>
154<td>
155                  <p>
156                    Connect the stream to the specified endpoint asynchronously.
157                  </p>
158                  <p>
159                    Establishes a connection by trying each endpoint in a sequence
160                    asynchronously.
161                  </p>
162                </td>
163</tr>
164<tr>
165<td>
166                  <p>
167                    <span class="bold"><strong><a class="link" href="../boost__beast__basic_stream/async_read_some.html" title="basic_stream::async_read_some">async_read_some</a></strong></span>
168                  </p>
169                </td>
170<td>
171                  <p>
172                    Read some data asynchronously.
173                  </p>
174                </td>
175</tr>
176<tr>
177<td>
178                  <p>
179                    <span class="bold"><strong><a class="link" href="../boost__beast__basic_stream/async_write_some.html" title="basic_stream::async_write_some">async_write_some</a></strong></span>
180                  </p>
181                </td>
182<td>
183                  <p>
184                    Write some data asynchronously.
185                  </p>
186                </td>
187</tr>
188<tr>
189<td>
190                  <p>
191                    <span class="bold"><strong><a class="link" href="../boost__beast__basic_stream/basic_stream.html" title="basic_stream::basic_stream">basic_stream</a></strong></span>
192                  </p>
193                </td>
194<td>
195                  <p>
196                    Constructor.
197                  </p>
198                  <p>
199                    Move constructor.
200                  </p>
201                </td>
202</tr>
203<tr>
204<td>
205                  <p>
206                    <span class="bold"><strong><a class="link" href="../boost__beast__basic_stream/cancel.html" title="basic_stream::cancel">cancel</a></strong></span>
207                  </p>
208                </td>
209<td>
210                  <p>
211                    Cancel all asynchronous operations associated with the socket.
212                  </p>
213                </td>
214</tr>
215<tr>
216<td>
217                  <p>
218                    <span class="bold"><strong><a class="link" href="../boost__beast__basic_stream/close.html" title="basic_stream::close">close</a></strong></span>
219                  </p>
220                </td>
221<td>
222                  <p>
223                    Close the timed stream.
224                  </p>
225                </td>
226</tr>
227<tr>
228<td>
229                  <p>
230                    <span class="bold"><strong><a class="link" href="../boost__beast__basic_stream/connect.html" title="basic_stream::connect">connect</a></strong></span>
231                  </p>
232                </td>
233<td>
234                  <p>
235                    Connect the stream to the specified endpoint.
236                  </p>
237                  <p>
238                    Establishes a connection by trying each endpoint in a sequence.
239                  </p>
240                </td>
241</tr>
242<tr>
243<td>
244                  <p>
245                    <span class="bold"><strong><a class="link" href="../boost__beast__basic_stream/expires_after.html" title="basic_stream::expires_after">expires_after</a></strong></span>
246                  </p>
247                </td>
248<td>
249                  <p>
250                    Set the timeout for the next logical operation.
251                  </p>
252                </td>
253</tr>
254<tr>
255<td>
256                  <p>
257                    <span class="bold"><strong><a class="link" href="../boost__beast__basic_stream/expires_at.html" title="basic_stream::expires_at">expires_at</a></strong></span>
258                  </p>
259                </td>
260<td>
261                  <p>
262                    Set the timeout for the next logical operation.
263                  </p>
264                </td>
265</tr>
266<tr>
267<td>
268                  <p>
269                    <span class="bold"><strong><a class="link" href="../boost__beast__basic_stream/expires_never.html" title="basic_stream::expires_never">expires_never</a></strong></span>
270                  </p>
271                </td>
272<td>
273                  <p>
274                    Disable the timeout for the next logical operation.
275                  </p>
276                </td>
277</tr>
278<tr>
279<td>
280                  <p>
281                    <span class="bold"><strong><a class="link" href="../boost__beast__basic_stream/get_executor.html" title="basic_stream::get_executor">get_executor</a></strong></span>
282                  </p>
283                </td>
284<td>
285                  <p>
286                    Get the executor associated with the object.
287                  </p>
288                </td>
289</tr>
290<tr>
291<td>
292                  <p>
293                    <span class="bold"><strong><a class="link" href="../boost__beast__basic_stream/operator_eq_.html" title="basic_stream::operator=">operator=</a></strong></span>
294                  </p>
295                </td>
296<td>
297                  <p>
298                    Move assignment (deleted).
299                  </p>
300                </td>
301</tr>
302<tr>
303<td>
304                  <p>
305                    <span class="bold"><strong><a class="link" href="../boost__beast__basic_stream/rate_policy.html" title="basic_stream::rate_policy">rate_policy</a></strong></span>
306                  </p>
307                </td>
308<td>
309                  <p>
310                    Returns the rate policy associated with the object.
311                  </p>
312                </td>
313</tr>
314<tr>
315<td>
316                  <p>
317                    <span class="bold"><strong><a class="link" href="../boost__beast__basic_stream/read_some.html" title="basic_stream::read_some">read_some</a></strong></span>
318                  </p>
319                </td>
320<td>
321                  <p>
322                    Read some data.
323                  </p>
324                </td>
325</tr>
326<tr>
327<td>
328                  <p>
329                    <span class="bold"><strong><a class="link" href="../boost__beast__basic_stream/release_socket.html" title="basic_stream::release_socket">release_socket</a></strong></span>
330                  </p>
331                </td>
332<td>
333                  <p>
334                    Release ownership of the underlying socket.
335                  </p>
336                </td>
337</tr>
338<tr>
339<td>
340                  <p>
341                    <span class="bold"><strong><a class="link" href="../boost__beast__basic_stream/socket.html" title="basic_stream::socket">socket</a></strong></span>
342                  </p>
343                </td>
344<td>
345                  <p>
346                    Return a reference to the underlying socket.
347                  </p>
348                </td>
349</tr>
350<tr>
351<td>
352                  <p>
353                    <span class="bold"><strong><a class="link" href="../boost__beast__basic_stream/write_some.html" title="basic_stream::write_some">write_some</a></strong></span>
354                  </p>
355                </td>
356<td>
357                  <p>
358                    Write some data.
359                  </p>
360                </td>
361</tr>
362<tr>
363<td>
364                  <p>
365                    <span class="bold"><strong><a class="link" href="../boost__beast__basic_stream/_basic_stream.html" title="basic_stream::~basic_stream">~basic_stream</a></strong></span>
366                  </p>
367                </td>
368<td>
369                  <p>
370                    Destructor.
371                  </p>
372                </td>
373</tr>
374</tbody>
375</table></div>
376<p>
377          This stream wraps a <code class="computeroutput"><span class="identifier">net</span><span class="special">::</span><span class="identifier">basic_stream_socket</span></code>
378          to provide the following features:
379        </p>
380<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
381<li class="listitem">
382              An <span class="emphasis"><em>Executor</em></span> may be associated with the stream,
383              which will be used to invoke any completion handlers which do not already
384              have an associated executor. This achieves support for <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1322r0.html" target="_top">[P1322R0]
385              Networking TS enhancement to enable custom I/O executors</a>.
386            </li>
387<li class="listitem">
388              Timeouts may be specified for each logical asynchronous operation performing
389              any reading, writing, or connecting.
390            </li>
391<li class="listitem">
392              A <span class="emphasis"><em>RatePolicy</em></span> may be associated with the stream,
393              to implement rate limiting through the policy's interface.
394            </li>
395</ul></div>
396<p>
397          Although the stream supports multiple concurrent outstanding asynchronous
398          operations, the stream object is not thread-safe. The caller is responsible
399          for ensuring that the stream is accessed from only one thread at a time.
400          This includes the times when the stream, and its underlying socket, are
401          accessed by the networking implementation. To meet this thread safety requirement,
402          all asynchronous operations must be performed by the stream within the
403          same implicit strand (only one thread <code class="computeroutput"><span class="identifier">net</span><span class="special">::</span><span class="identifier">io_context</span><span class="special">::</span><span class="identifier">run</span></code>)
404          or within the same explicit strand, such as an instance of <code class="computeroutput"><span class="identifier">net</span><span class="special">::</span><span class="identifier">strand</span></code>. Completion handlers with explicit
405          associated executors (such as those arising from use of <code class="computeroutput"><span class="identifier">net</span><span class="special">::</span><span class="identifier">bind_executor</span></code>)
406          will be invoked by the stream using the associated executor. Otherwise,
407          the completion handler will be invoked by the executor associated with
408          the stream upon construction. The type of executor used with this stream
409          must meet the following requirements:
410        </p>
411<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
412              Function objects submitted to the executor shall never run concurrently
413              with each other.
414            </li></ul></div>
415<p>
416          The executor type <code class="computeroutput"><span class="identifier">net</span><span class="special">::</span><span class="identifier">strand</span></code> meets these requirements. Use
417          of a strand as the executor in the stream class template offers an additional
418          notational convenience: the strand does not need to be specified in each
419          individual initiating function call. Unlike other stream wrappers, the
420          underlying socket is accessed through the <a class="link" href="../boost__beast__basic_stream/socket/overload1.html" title="basic_stream::socket (1 of 2 overloads)"><code class="computeroutput"><span class="identifier">socket</span></code></a> member function instead
421          of <code class="computeroutput"><span class="identifier">next_layer</span></code>. This causes
422          the <a class="link" href="../boost__beast__basic_stream.html" title="basic_stream"><code class="computeroutput"><span class="identifier">basic_stream</span></code></a> to be returned in
423          calls to <a class="link" href="../boost__beast__get_lowest_layer.html" title="get_lowest_layer"><code class="computeroutput"><span class="identifier">get_lowest_layer</span></code></a>.
424        </p>
425<h6>
426<a name="beast.ref.boost__beast__basic_stream__rebind_executor.other.h3"></a>
427          <span class="phrase"><a name="beast.ref.boost__beast__basic_stream__rebind_executor.other.usage"></a></span><a class="link" href="other.html#beast.ref.boost__beast__basic_stream__rebind_executor.other.usage">Usage</a>
428        </h6>
429<p>
430          To use this stream declare an instance of the class. Then, before each
431          logical operation for which a timeout is desired, call <a class="link" href="../boost__beast__basic_stream/expires_after.html" title="basic_stream::expires_after"><code class="computeroutput"><span class="identifier">expires_after</span></code></a> with a duration,
432          or call <a class="link" href="../boost__beast__basic_stream/expires_at.html" title="basic_stream::expires_at"><code class="computeroutput"><span class="identifier">expires_at</span></code></a> with a time point.
433          Alternatively, call <a class="link" href="../boost__beast__basic_stream/expires_never.html" title="basic_stream::expires_never"><code class="computeroutput"><span class="identifier">expires_never</span></code></a> to disable the timeout
434          for subsequent logical operations. A logical operation is any series of
435          one or more direct or indirect calls to the timeout stream's asynchronous
436          read, asynchronous write, or asynchronous connect functions. When a timeout
437          is set and a mixed operation is performed (one that includes both reads
438          and writes, for example) the timeout applies to all of the intermediate
439          asynchronous operations used in the enclosing operation. This allows timeouts
440          to be applied to stream algorithms which were not written specifically
441          to allow for timeouts, when those algorithms are passed a timeout stream
442          with a timeout set. When a timeout occurs the socket will be closed, canceling
443          any pending I/O operations. The completion handlers for these canceled
444          operations will be invoked with the error <a class="link" href="../boost__beast__error.html" title="error"><code class="computeroutput"><span class="identifier">beast</span><span class="special">::</span><span class="identifier">error</span><span class="special">::</span><span class="identifier">timeout</span></code></a>.
445        </p>
446<h6>
447<a name="beast.ref.boost__beast__basic_stream__rebind_executor.other.h4"></a>
448          <span class="phrase"><a name="beast.ref.boost__beast__basic_stream__rebind_executor.other.examples"></a></span><a class="link" href="other.html#beast.ref.boost__beast__basic_stream__rebind_executor.other.examples">Examples</a>
449        </h6>
450<p>
451          This function reads an HTTP request with a timeout, then sends the HTTP
452          response with a different timeout.
453        </p>
454<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">process_http_1</span> <span class="special">(</span><span class="identifier">tcp_stream</span><span class="special">&amp;</span> <span class="identifier">stream</span><span class="special">,</span> <span class="identifier">net</span><span class="special">::</span><span class="identifier">yield_context</span> <span class="identifier">yield</span><span class="special">)</span>
455<span class="special">{</span>
456    <span class="identifier">flat_buffer</span> <span class="identifier">buffer</span><span class="special">;</span>
457    <span class="identifier">http</span><span class="special">::</span><span class="identifier">request</span><span class="special">&lt;</span><span class="identifier">http</span><span class="special">::</span><span class="identifier">empty_body</span><span class="special">&gt;</span> <span class="identifier">req</span><span class="special">;</span>
458
459    <span class="comment">// Read the request, with a 15 second timeout</span>
460    <span class="identifier">stream</span><span class="special">.</span><span class="identifier">expires_after</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">chrono</span><span class="special">::</span><span class="identifier">seconds</span><span class="special">(</span><span class="number">15</span><span class="special">));</span>
461    <span class="identifier">http</span><span class="special">::</span><span class="identifier">async_read</span><span class="special">(</span><span class="identifier">stream</span><span class="special">,</span> <span class="identifier">buffer</span><span class="special">,</span> <span class="identifier">req</span><span class="special">,</span> <span class="identifier">yield</span><span class="special">);</span>
462
463    <span class="comment">// Calculate the response</span>
464    <span class="identifier">http</span><span class="special">::</span><span class="identifier">response</span><span class="special">&lt;</span><span class="identifier">http</span><span class="special">::</span><span class="identifier">string_body</span><span class="special">&gt;</span> <span class="identifier">res</span> <span class="special">=</span> <span class="identifier">make_response</span><span class="special">(</span><span class="identifier">req</span><span class="special">);</span>
465
466    <span class="comment">// Send the response, with a 30 second timeout.</span>
467    <span class="identifier">stream</span><span class="special">.</span><span class="identifier">expires_after</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">chrono</span><span class="special">::</span><span class="identifier">seconds</span><span class="special">(</span><span class="number">30</span><span class="special">));</span>
468    <span class="identifier">http</span><span class="special">::</span><span class="identifier">async_write</span> <span class="special">(</span><span class="identifier">stream</span><span class="special">,</span> <span class="identifier">res</span><span class="special">,</span> <span class="identifier">yield</span><span class="special">);</span>
469<span class="special">}</span>
470</pre>
471<p>
472          The example above could be expressed using a single timeout with a simple
473          modification. The function that follows first reads an HTTP request then
474          sends the HTTP response, with a single timeout that applies to the entire
475          combined operation of reading and writing:
476        </p>
477<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">process_http_2</span> <span class="special">(</span><span class="identifier">tcp_stream</span><span class="special">&amp;</span> <span class="identifier">stream</span><span class="special">,</span> <span class="identifier">net</span><span class="special">::</span><span class="identifier">yield_context</span> <span class="identifier">yield</span><span class="special">)</span>
478<span class="special">{</span>
479    <span class="identifier">flat_buffer</span> <span class="identifier">buffer</span><span class="special">;</span>
480    <span class="identifier">http</span><span class="special">::</span><span class="identifier">request</span><span class="special">&lt;</span><span class="identifier">http</span><span class="special">::</span><span class="identifier">empty_body</span><span class="special">&gt;</span> <span class="identifier">req</span><span class="special">;</span>
481
482    <span class="comment">// Require that the read and write combined take no longer than 30 seconds</span>
483    <span class="identifier">stream</span><span class="special">.</span><span class="identifier">expires_after</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">chrono</span><span class="special">::</span><span class="identifier">seconds</span><span class="special">(</span><span class="number">30</span><span class="special">));</span>
484
485    <span class="identifier">http</span><span class="special">::</span><span class="identifier">async_read</span><span class="special">(</span><span class="identifier">stream</span><span class="special">,</span> <span class="identifier">buffer</span><span class="special">,</span> <span class="identifier">req</span><span class="special">,</span> <span class="identifier">yield</span><span class="special">);</span>
486
487    <span class="identifier">http</span><span class="special">::</span><span class="identifier">response</span><span class="special">&lt;</span><span class="identifier">http</span><span class="special">::</span><span class="identifier">string_body</span><span class="special">&gt;</span> <span class="identifier">res</span> <span class="special">=</span> <span class="identifier">make_response</span><span class="special">(</span><span class="identifier">req</span><span class="special">);</span>
488    <span class="identifier">http</span><span class="special">::</span><span class="identifier">async_write</span> <span class="special">(</span><span class="identifier">stream</span><span class="special">,</span> <span class="identifier">res</span><span class="special">,</span> <span class="identifier">yield</span><span class="special">);</span>
489<span class="special">}</span>
490</pre>
491<p>
492          Some stream algorithms, such as <code class="computeroutput"><span class="identifier">ssl</span><span class="special">::</span><span class="identifier">stream</span><span class="special">::</span><span class="identifier">async_handshake</span></code>
493          perform both reads and writes. A timeout set before calling the initiating
494          function of such composite stream algorithms will apply to the entire composite
495          operation. For example, a timeout may be set on performing the SSL handshake
496          thusly:
497        </p>
498<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">do_ssl_handshake</span> <span class="special">(</span><span class="identifier">net</span><span class="special">::</span><span class="identifier">ssl</span><span class="special">::</span><span class="identifier">stream</span><span class="special">&lt;</span><span class="identifier">tcp_stream</span><span class="special">&gt;&amp;</span> <span class="identifier">stream</span><span class="special">,</span> <span class="identifier">net</span><span class="special">::</span><span class="identifier">yield_context</span> <span class="identifier">yield</span><span class="special">)</span>
499<span class="special">{</span>
500    <span class="comment">// Require that the SSL handshake take no longer than 10 seconds</span>
501    <span class="identifier">stream</span><span class="special">.</span><span class="identifier">expires_after</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">chrono</span><span class="special">::</span><span class="identifier">seconds</span><span class="special">(</span><span class="number">10</span><span class="special">));</span>
502
503    <span class="identifier">stream</span><span class="special">.</span><span class="identifier">async_handshake</span><span class="special">(</span><span class="identifier">net</span><span class="special">::</span><span class="identifier">ssl</span><span class="special">::</span><span class="identifier">stream_base</span><span class="special">::</span><span class="identifier">client</span><span class="special">,</span> <span class="identifier">yield</span><span class="special">);</span>
504<span class="special">}</span>
505</pre>
506<h6>
507<a name="beast.ref.boost__beast__basic_stream__rebind_executor.other.h5"></a>
508          <span class="phrase"><a name="beast.ref.boost__beast__basic_stream__rebind_executor.other.blocking_i_o"></a></span><a class="link" href="other.html#beast.ref.boost__beast__basic_stream__rebind_executor.other.blocking_i_o">Blocking
509          I/O</a>
510        </h6>
511<p>
512          Synchronous functions behave identically as that of the wrapped <code class="computeroutput"><span class="identifier">net</span><span class="special">::</span><span class="identifier">basic_stream_socket</span></code>. Timeouts are not
513          available when performing blocking calls.
514        </p>
515<h6>
516<a name="beast.ref.boost__beast__basic_stream__rebind_executor.other.h6"></a>
517          <span class="phrase"><a name="beast.ref.boost__beast__basic_stream__rebind_executor.other.template_parameters"></a></span><a class="link" href="other.html#beast.ref.boost__beast__basic_stream__rebind_executor.other.template_parameters">Template
518          Parameters</a>
519        </h6>
520<div class="informaltable"><table class="table">
521<colgroup>
522<col>
523<col>
524</colgroup>
525<thead><tr>
526<th>
527                  <p>
528                    Type
529                  </p>
530                </th>
531<th>
532                  <p>
533                    Description
534                  </p>
535                </th>
536</tr></thead>
537<tbody>
538<tr>
539<td>
540                  <p>
541                    <code class="computeroutput"><span class="identifier">Protocol</span></code>
542                  </p>
543                </td>
544<td>
545                  <p>
546                    A type meeting the requirements of <span class="emphasis"><em>Protocol</em></span>
547                    representing the protocol the protocol to use for the basic stream
548                    socket. A common choice is <code class="computeroutput"><span class="identifier">net</span><span class="special">::</span><span class="identifier">ip</span><span class="special">::</span><span class="identifier">tcp</span></code>.
549                  </p>
550                </td>
551</tr>
552<tr>
553<td>
554                  <p>
555                    <code class="computeroutput"><span class="identifier">Executor</span></code>
556                  </p>
557                </td>
558<td>
559                  <p>
560                    A type meeting the requirements of <span class="emphasis"><em>Executor</em></span>
561                    to be used for submitting all completion handlers which do not
562                    already have an associated executor. If this type is omitted,
563                    the default of <code class="computeroutput"><span class="identifier">net</span><span class="special">::</span><span class="identifier">any_io_executor</span></code>
564                    will be used.
565                  </p>
566                </td>
567</tr>
568</tbody>
569</table></div>
570<h6>
571<a name="beast.ref.boost__beast__basic_stream__rebind_executor.other.h7"></a>
572          <span class="phrase"><a name="beast.ref.boost__beast__basic_stream__rebind_executor.other.thread_safety"></a></span><a class="link" href="other.html#beast.ref.boost__beast__basic_stream__rebind_executor.other.thread_safety">Thread
573          Safety</a>
574        </h6>
575<p>
576          <span class="emphasis"><em>Distinct objects</em></span>: Safe.
577        </p>
578<p>
579          <span class="emphasis"><em>Shared objects</em></span>: Unsafe. The application must also
580          ensure that all asynchronous operations are performed within the same implicit
581          or explicit strand.
582        </p>
583<h6>
584<a name="beast.ref.boost__beast__basic_stream__rebind_executor.other.h8"></a>
585          <span class="phrase"><a name="beast.ref.boost__beast__basic_stream__rebind_executor.other.see_also"></a></span><a class="link" href="other.html#beast.ref.boost__beast__basic_stream__rebind_executor.other.see_also">See
586          Also</a>
587        </h6>
588<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
589              <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1322r0.html" target="_top">[P1322R0]
590              Networking TS enhancement to enable custom I/O executors</a>.
591            </li></ul></div>
592<h6>
593<a name="beast.ref.boost__beast__basic_stream__rebind_executor.other.h9"></a>
594          <span class="phrase"><a name="beast.ref.boost__beast__basic_stream__rebind_executor.other.description"></a></span><a class="link" href="other.html#beast.ref.boost__beast__basic_stream__rebind_executor.other.description">Description</a>
595        </h6>
596</div>
597<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
598<td align="left"></td>
599<td align="right"><div class="copyright-footer">Copyright © 2016-2019 Vinnie
600      Falco<p>
601        Distributed under the Boost Software License, Version 1.0. (See accompanying
602        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>)
603      </p>
604</div></td>
605</tr></table>
606<hr>
607<div class="spirit-nav">
608<a accesskey="p" href="../boost__beast__basic_stream__rebind_executor.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../boost__beast__basic_stream__rebind_executor.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__saved_handler.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
609</div>
610</body>
611</html>
612