• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>websocket::stream::read_some (1 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="../read_some.html" title="websocket::stream::read_some">
10<link rel="next" href="overload2.html" title="websocket::stream::read_some (2 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="../read_some.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="overload2.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.overload1"></a><a class="link" href="overload1.html" title="websocket::stream::read_some (1 of 4 overloads)">websocket::stream::read_some
28          (1 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.overload1.h0"></a>
34            <span class="phrase"><a name="beast.ref.boost__beast__websocket__stream.read_some.overload1.synopsis"></a></span><a class="link" href="overload1.html#beast.ref.boost__beast__websocket__stream.read_some.overload1.synopsis">Synopsis</a>
35          </h7><pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span>
36    <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">&gt;</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">DynamicBuffer</span><span class="special">&amp;</span> <span class="identifier">buffer</span><span class="special">,</span>
40    <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">limit</span><span class="special">);</span>
41</pre>
42<h7><a name="beast.ref.boost__beast__websocket__stream.read_some.overload1.h1"></a>
43            <span class="phrase"><a name="beast.ref.boost__beast__websocket__stream.read_some.overload1.description"></a></span><a class="link" href="overload1.html#beast.ref.boost__beast__websocket__stream.read_some.overload1.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            Received message data is appended to the buffer. 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.overload1.h2"></a>
86            <span class="phrase"><a name="beast.ref.boost__beast__websocket__stream.read_some.overload1.return_value"></a></span><a class="link" href="overload1.html#beast.ref.boost__beast__websocket__stream.read_some.overload1.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.overload1.h3"></a>
92            <span class="phrase"><a name="beast.ref.boost__beast__websocket__stream.read_some.overload1.parameters"></a></span><a class="link" href="overload1.html#beast.ref.boost__beast__websocket__stream.read_some.overload1.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">buffer</span></code>
115                    </p>
116                  </td>
117<td>
118                    <p>
119                      A dynamic buffer to append message data to.
120                    </p>
121                  </td>
122</tr>
123<tr>
124<td>
125                    <p>
126                      <code class="computeroutput"><span class="identifier">limit</span></code>
127                    </p>
128                  </td>
129<td>
130                    <p>
131                      An upper limit on the number of bytes this function will append
132                      into the buffer. If this value is zero, then a reasonable size
133                      will be chosen automatically.
134                    </p>
135                  </td>
136</tr>
137</tbody>
138</table></div>
139<h7><a name="beast.ref.boost__beast__websocket__stream.read_some.overload1.h4"></a>
140            <span class="phrase"><a name="beast.ref.boost__beast__websocket__stream.read_some.overload1.exceptions"></a></span><a class="link" href="overload1.html#beast.ref.boost__beast__websocket__stream.read_some.overload1.exceptions">Exceptions</a>
141          </h7><div class="informaltable"><table class="table">
142<colgroup>
143<col>
144<col>
145</colgroup>
146<thead><tr>
147<th>
148                    <p>
149                      Type
150                    </p>
151                  </th>
152<th>
153                    <p>
154                      Thrown On
155                    </p>
156                  </th>
157</tr></thead>
158<tbody><tr>
159<td>
160                    <p>
161                      <code class="computeroutput"><span class="identifier">system_error</span></code>
162                    </p>
163                  </td>
164<td>
165                    <p>
166                      Thrown on failure.
167                    </p>
168                  </td>
169</tr></tbody>
170</table></div>
171</div>
172<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
173<td align="left"></td>
174<td align="right"><div class="copyright-footer">Copyright © 2016-2019 Vinnie
175      Falco<p>
176        Distributed under the Boost Software License, Version 1.0. (See accompanying
177        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>)
178      </p>
179</div></td>
180</tr></table>
181<hr>
182<div class="spirit-nav">
183<a accesskey="p" href="../read_some.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="overload2.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
184</div>
185</body>
186</html>
187