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