1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>get_lowest_layer</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__to_static_string.html" title="to_static_string"> 10<link rel="next" href="boost__beast__beast_close_socket.html" title="beast_close_socket"> 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__to_static_string.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__beast_close_socket.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__get_lowest_layer"></a><a class="link" href="boost__beast__get_lowest_layer.html" title="get_lowest_layer">get_lowest_layer</a> 28</h4></div></div></div> 29<p> 30 <a class="indexterm" name="idm46057511006208"></a> 31 </p> 32<p> 33 Return the lowest layer in a stack of stream layers. 34 </p> 35<h5> 36<a name="beast.ref.boost__beast__get_lowest_layer.h0"></a> 37 <span class="phrase"><a name="beast.ref.boost__beast__get_lowest_layer.synopsis"></a></span><a class="link" href="boost__beast__get_lowest_layer.html#beast.ref.boost__beast__get_lowest_layer.synopsis">Synopsis</a> 38 </h5> 39<p> 40 Defined in header <code class="literal"><<a href="../../../../../../boost/beast/core/stream_traits.hpp" target="_top">boost/beast/core/stream_traits.hpp</a>></code> 41 </p> 42<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> 43 <span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> 44<span class="identifier">lowest_layer_type</span><span class="special"><</span> <span class="identifier">T</span> <span class="special">>&</span> 45<span class="identifier">get_lowest_layer</span><span class="special">(</span> 46 <span class="identifier">T</span><span class="special">&</span> <span class="identifier">t</span><span class="special">);</span> 47</pre> 48<h5> 49<a name="beast.ref.boost__beast__get_lowest_layer.h1"></a> 50 <span class="phrase"><a name="beast.ref.boost__beast__get_lowest_layer.description"></a></span><a class="link" href="boost__beast__get_lowest_layer.html#beast.ref.boost__beast__get_lowest_layer.description">Description</a> 51 </h5> 52<p> 53 If <code class="computeroutput"><span class="identifier">t</span><span class="special">.</span><span class="identifier">next_layer</span><span class="special">()</span></code> 54 is well-defined, returns <code class="computeroutput"><span class="identifier">get_lowest_layer</span><span class="special">(</span><span class="identifier">t</span><span class="special">.</span><span class="identifier">next_layer</span><span class="special">())</span></code>. 55 Otherwise, it returns <code class="computeroutput"><span class="identifier">t</span></code>. 56 A stream layer is an object of class type which wraps another object through 57 composition, and meets some or all of the named requirements of the wrapped 58 type while optionally changing behavior. Examples of stream layers include 59 <code class="computeroutput"><span class="identifier">net</span><span class="special">::</span><span class="identifier">ssl</span><span class="special">::</span><span class="identifier">stream</span></code> 60 or <a class="link" href="boost__beast__websocket__stream.html" title="websocket::stream"><code class="computeroutput"><span class="identifier">beast</span><span class="special">::</span><span class="identifier">websocket</span><span class="special">::</span><span class="identifier">stream</span></code></a>. The owner of a stream layer 61 can interact directly with the wrapper, by passing it to stream algorithms. 62 Or, the owner can obtain a reference to the wrapped object by calling <code class="computeroutput"><span class="identifier">next_layer</span><span class="special">()</span></code> 63 and accessing its members. This is necessary when it is desired to access 64 functionality in the next layer which is not available in the wrapper. For 65 example, <a class="link" href="boost__beast__websocket__stream.html" title="websocket::stream"><code class="computeroutput"><span class="identifier">websocket</span><span class="special">::</span><span class="identifier">stream</span></code></a> permits reading and writing, 66 but in order to establish the underlying connection, members of the wrapped 67 stream (such as <code class="computeroutput"><span class="identifier">connect</span></code>) 68 must be invoked directly. Usually the last object in the chain of composition 69 is the concrete socket object (for example, a <code class="computeroutput"><span class="identifier">net</span><span class="special">::</span><span class="identifier">basic_socket</span></code> 70 or a class derived from it). The function <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> exists to easily 71 obtain the concrete socket when it is desired to perform an action that is 72 not prescribed by a named requirement, such as changing a socket option, 73 cancelling all pending asynchronous I/O, or closing the socket (perhaps by 74 using <a class="link" href="boost__beast__close_socket.html" title="close_socket"><code class="computeroutput"><span class="identifier">close_socket</span></code></a>). 75 </p> 76<h5> 77<a name="beast.ref.boost__beast__get_lowest_layer.h2"></a> 78 <span class="phrase"><a name="beast.ref.boost__beast__get_lowest_layer.example"></a></span><a class="link" href="boost__beast__get_lowest_layer.html#beast.ref.boost__beast__get_lowest_layer.example">Example</a> 79 </h5> 80<pre class="programlisting"><span class="comment">// Set non-blocking mode on a stack of stream</span> 81<span class="comment">// layers with a regular socket at the lowest layer.</span> 82<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Stream</span><span class="special">></span> 83<span class="keyword">void</span> <span class="identifier">set_non_blocking</span> <span class="special">(</span><span class="identifier">Stream</span><span class="special">&</span> <span class="identifier">stream</span><span class="special">)</span> 84<span class="special">{</span> 85 <span class="identifier">error_code</span> <span class="identifier">ec</span><span class="special">;</span> 86 <span class="comment">// A compile error here means your lowest layer is not the right type!</span> 87 <span class="identifier">get_lowest_layer</span><span class="special">(</span><span class="identifier">stream</span><span class="special">).</span><span class="identifier">non_blocking</span><span class="special">(</span><span class="keyword">true</span><span class="special">,</span> <span class="identifier">ec</span><span class="special">);</span> 88 <span class="keyword">if</span><span class="special">(</span><span class="identifier">ec</span><span class="special">)</span> 89 <span class="keyword">throw</span> <span class="identifier">system_error</span><span class="special">{</span><span class="identifier">ec</span><span class="special">};</span> 90<span class="special">}</span> 91</pre> 92<h5> 93<a name="beast.ref.boost__beast__get_lowest_layer.h3"></a> 94 <span class="phrase"><a name="beast.ref.boost__beast__get_lowest_layer.parameters"></a></span><a class="link" href="boost__beast__get_lowest_layer.html#beast.ref.boost__beast__get_lowest_layer.parameters">Parameters</a> 95 </h5> 96<div class="informaltable"><table class="table"> 97<colgroup> 98<col> 99<col> 100</colgroup> 101<thead><tr> 102<th> 103 <p> 104 Name 105 </p> 106 </th> 107<th> 108 <p> 109 Description 110 </p> 111 </th> 112</tr></thead> 113<tbody><tr> 114<td> 115 <p> 116 <code class="computeroutput"><span class="identifier">t</span></code> 117 </p> 118 </td> 119<td> 120 <p> 121 The layer in a stack of layered objects for which the lowest layer 122 is returned. 123 </p> 124 </td> 125</tr></tbody> 126</table></div> 127<h5> 128<a name="beast.ref.boost__beast__get_lowest_layer.h4"></a> 129 <span class="phrase"><a name="beast.ref.boost__beast__get_lowest_layer.see_also"></a></span><a class="link" href="boost__beast__get_lowest_layer.html#beast.ref.boost__beast__get_lowest_layer.see_also">See 130 Also</a> 131 </h5> 132<p> 133 <a class="link" href="boost__beast__close_socket.html" title="close_socket"><code class="computeroutput"><span class="identifier">close_socket</span></code></a>, 134 <a class="link" href="boost__beast__lowest_layer_type.html" title="lowest_layer_type"><code class="computeroutput"><span class="identifier">lowest_layer_type</span></code></a> 135 </p> 136</div> 137<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 138<td align="left"></td> 139<td align="right"><div class="copyright-footer">Copyright © 2016-2019 Vinnie 140 Falco<p> 141 Distributed under the Boost Software License, Version 1.0. (See accompanying 142 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>) 143 </p> 144</div></td> 145</tr></table> 146<hr> 147<div class="spirit-nav"> 148<a accesskey="p" href="boost__beast__to_static_string.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__beast_close_socket.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 149</div> 150</body> 151</html> 152