1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>websocket::stream::read_some (3 of 4 overloads)</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="../read_some.html" title="websocket::stream::read_some"> 9<link rel="prev" href="overload2.html" title="websocket::stream::read_some (2 of 4 overloads)"> 10<link rel="next" href="overload4.html" title="websocket::stream::read_some (4 of 4 overloads)"> 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="overload2.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../read_some.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="overload4.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h6 class="title"> 27<a name="beast.ref.boost__beast__websocket__stream.read_some.overload3"></a><a class="link" href="overload3.html" title="websocket::stream::read_some (3 of 4 overloads)">websocket::stream::read_some 28 (3 of 4 overloads)</a> 29</h6></div></div></div> 30<p> 31 Read some message data. 32 </p> 33<h7><a name="beast.ref.boost__beast__websocket__stream.read_some.overload3.h0"></a> 34 <span class="phrase"><a name="beast.ref.boost__beast__websocket__stream.read_some.overload3.synopsis"></a></span><a class="link" href="overload3.html#beast.ref.boost__beast__websocket__stream.read_some.overload3.synopsis">Synopsis</a> 35 </h7><pre class="programlisting"><span class="keyword">template</span><span class="special"><</span> 36 <span class="keyword">class</span> <a href="../../../../../../../../doc/html/boost_asio/reference/MutableBufferSequence.html" target="_top"><span class="emphasis"><em>MutableBufferSequence</em></span></a><span class="special">></span> 37<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> 38<span class="identifier">read_some</span><span class="special">(</span> 39 <span class="identifier">MutableBufferSequence</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">buffers</span><span class="special">);</span> 40</pre> 41<h7><a name="beast.ref.boost__beast__websocket__stream.read_some.overload3.h1"></a> 42 <span class="phrase"><a name="beast.ref.boost__beast__websocket__stream.read_some.overload3.description"></a></span><a class="link" href="overload3.html#beast.ref.boost__beast__websocket__stream.read_some.overload3.description">Description</a> 43 </h7><p> 44 This function is used to read some message data. The call blocks until 45 one of the following is true: 46 </p> 47<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 48<li class="listitem"> 49 Some message data is received. 50 </li> 51<li class="listitem"> 52 A close frame is received. In this case the error indicated by the 53 function will be <a class="link" href="../../boost__beast__websocket__error.html" title="websocket::error"><code class="computeroutput"><span class="identifier">error</span><span class="special">::</span><span class="identifier">closed</span></code></a>. 54 </li> 55<li class="listitem"> 56 An error occurs. 57 </li> 58</ul></div> 59<p> 60 The algorithm, known as a <span class="emphasis"><em>composed operation</em></span>, is 61 implemented in terms of calls to the next layer's <code class="computeroutput"><span class="identifier">read_some</span></code> 62 and <code class="computeroutput"><span class="identifier">write_some</span></code> functions. 63 The functions <a class="link" href="../got_binary.html" title="websocket::stream::got_binary"><code class="computeroutput"><span class="identifier">got_binary</span></code></a> and <a class="link" href="../got_text.html" title="websocket::stream::got_text"><code class="computeroutput"><span class="identifier">got_text</span></code></a> may be used to query 64 the stream and determine the type of the last received message. The function 65 <a class="link" href="../is_message_done.html" title="websocket::stream::is_message_done"><code class="computeroutput"><span class="identifier">is_message_done</span></code></a> may be called 66 to determine if the message received by the last read operation is complete. 67 Until the call returns, the implementation will read incoming control 68 frames and handle them automatically as follows: 69 </p> 70<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 71<li class="listitem"> 72 The <a class="link" href="../control_callback/overload1.html" title="websocket::stream::control_callback (1 of 2 overloads)"><code class="computeroutput"><span class="identifier">control_callback</span></code></a> will be 73 invoked for each control frame. 74 </li> 75<li class="listitem"> 76 For each received ping frame, a pong frame will be automatically 77 sent. 78 </li> 79<li class="listitem"> 80 If a close frame is received, the WebSocket closing handshake is 81 performed. In this case, when the function returns, the error <a class="link" href="../../boost__beast__websocket__error.html" title="websocket::error"><code class="computeroutput"><span class="identifier">error</span><span class="special">::</span><span class="identifier">closed</span></code></a> will be indicated. 82 </li> 83</ul></div> 84<h7><a name="beast.ref.boost__beast__websocket__stream.read_some.overload3.h2"></a> 85 <span class="phrase"><a name="beast.ref.boost__beast__websocket__stream.read_some.overload3.return_value"></a></span><a class="link" href="overload3.html#beast.ref.boost__beast__websocket__stream.read_some.overload3.return_value">Return 86 Value</a> 87 </h7><p> 88 The number of message payload bytes appended to the buffer. 89 </p> 90<h7><a name="beast.ref.boost__beast__websocket__stream.read_some.overload3.h3"></a> 91 <span class="phrase"><a name="beast.ref.boost__beast__websocket__stream.read_some.overload3.parameters"></a></span><a class="link" href="overload3.html#beast.ref.boost__beast__websocket__stream.read_some.overload3.parameters">Parameters</a> 92 </h7><div class="informaltable"><table class="table"> 93<colgroup> 94<col> 95<col> 96</colgroup> 97<thead><tr> 98<th> 99 <p> 100 Name 101 </p> 102 </th> 103<th> 104 <p> 105 Description 106 </p> 107 </th> 108</tr></thead> 109<tbody><tr> 110<td> 111 <p> 112 <code class="computeroutput"><span class="identifier">buffers</span></code> 113 </p> 114 </td> 115<td> 116 <p> 117 A buffer sequence to write message data into. The previous 118 contents of the buffers will be overwritten, starting from 119 the beginning. 120 </p> 121 </td> 122</tr></tbody> 123</table></div> 124<h7><a name="beast.ref.boost__beast__websocket__stream.read_some.overload3.h4"></a> 125 <span class="phrase"><a name="beast.ref.boost__beast__websocket__stream.read_some.overload3.exceptions"></a></span><a class="link" href="overload3.html#beast.ref.boost__beast__websocket__stream.read_some.overload3.exceptions">Exceptions</a> 126 </h7><div class="informaltable"><table class="table"> 127<colgroup> 128<col> 129<col> 130</colgroup> 131<thead><tr> 132<th> 133 <p> 134 Type 135 </p> 136 </th> 137<th> 138 <p> 139 Thrown On 140 </p> 141 </th> 142</tr></thead> 143<tbody><tr> 144<td> 145 <p> 146 <code class="computeroutput"><span class="identifier">system_error</span></code> 147 </p> 148 </td> 149<td> 150 <p> 151 Thrown on failure. 152 </p> 153 </td> 154</tr></tbody> 155</table></div> 156</div> 157<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 158<td align="left"></td> 159<td align="right"><div class="copyright-footer">Copyright © 2016-2019 Vinnie 160 Falco<p> 161 Distributed under the Boost Software License, Version 1.0. (See accompanying 162 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>) 163 </p> 164</div></td> 165</tr></table> 166<hr> 167<div class="spirit-nav"> 168<a accesskey="p" href="overload2.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../read_some.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="overload4.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 169</div> 170</body> 171</html> 172