MCPcopy Create free account
hub / github.com/boostorg/beast / snippets

Function snippets

test/doc/websocket_8_notes.cpp:28–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26#include "websocket_common.ipp"
27
28void
29snippets()
30{
31 stream<tcp_stream> ws(ioc);
32
33 {
34 //[code_websocket_8_1
35
36 flat_buffer buffer;
37
38 ws.async_read(buffer,
39 [](error_code, std::size_t)
40 {
41 // Do something with the buffer
42 });
43
44 //]
45 }
46
47 multi_buffer b;
48
49 {
50 //[code_websocket_8_2
51
52 ws.async_read(b, [](error_code, std::size_t){});
53 ws.async_read(b, [](error_code, std::size_t){});
54
55 //]
56 }
57
58 {
59 //[code_websocket_8_3
60
61 ws.async_read(b, [](error_code, std::size_t){});
62 ws.async_write(b.data(), [](error_code, std::size_t){});
63 ws.async_ping({}, [](error_code){});
64 ws.async_close({}, [](error_code){});
65
66 //]
67 }
68}
69
70// workaround for https://github.com/chriskohlhoff/asio/issues/112
71//#ifdef BOOST_MSVC

Callers

nothing calls this directly

Calls 3

async_readMethod · 0.80
dataMethod · 0.45
async_closeMethod · 0.45

Tested by

no test coverage detected