Questions tagged [beast-websockets]

1

votes
1

answer
607

Views

How to pass read handler to async_read for Beast websocket?

How do I pass in a callback to async_read? I tried the following but it won't compile. I based this off of modifying code from the docs #include #include #include #include #include #include #include #include #include #include #include #include using tcp = boost::asio::ip::tcp; namespace...
user782220
1

votes
1

answer
377

Views

boost-beast websocket server that also accept http connections

I need to implement a simple asynchronous websocket server using boost beast that can accept both websocket and standard http connections. I've tried something like this: ... // ws is a boost::beast::websocket::stream ws.async_accept_ex( [](boost::beast::websocket::response_type& res) { res.set(boos...
1

votes
1

answer
0

Views

How to read the header of a bad request in beast::websocket?

I have a websocket server(listening the loopback interface) that should respond to a GET request. Here's how I do that ws_.async_accept_ex( [self = shared_from_this()](websocket::response_type& res) // { if (res.result_int() == 400) { // bad request, assume HTTP GET osstream response; /* invoke requ...
Johnny
1

votes
1

answer
0

Views

Boost beast manupulate http response headers durring accept

I would like to manipulate the http response sent to the websocket client durring accept. I've read the examples and the manual, I can pare the request, check if it's a websocket upgrade request, but I can't manipulate the response. It would be nice to have the websocket library to prepare the respo...
E.T.
1

votes
1

answer
35

Views

Store a STL map into a Boost ConstBufferSequence

I'm trying to store a std::map in a boost::beast::multi_buffer. So far I've been using boost::asio::buffer_copy and boost::asio::buffer to store vectors and PODs. However, I couldn't find a way to store a STL map. I've tried this: auto t_map = std::map(); // CODES is an enum type auto t_map_size = t...
Shmwel
1

votes
2

answer
41

Views

Call a boost function without callback

I am using boost-beast library for a websocket connection. You can refer to this example for the understanding what is happening. I have used the same example, but changed a few things: split the on_handshake(beast::error_code ec) into three functions A(beast::error_code ec),B(beast::error_code ec)...
RC0993
1

votes
2

answer
1.9k

Views

How to do async read/write with Beast websockets

How can I do async write and read using websockets from the Beast library? I have tried to adapted the synchronous write/read example provided in the Beast documentation here, but the code below does not behave as expected. I expected the following output : *launch application* Written data ... Rece...
Eskilade
3

votes
2

answer
493

Views

How to do async read/write Beast websockets alongside read/write of files?

I have my C++ program that forks into two processes, 1 (the original) and 2 (the forked process). In the forked process (2), it execs program A that does a lot of computation. The original process (1) communicates with that program A through standard input and output redirected to pipes. I am trying...
user782220