I am trying out Boost Beast examples for asynchronous web socket server - client
I am running server and client as below,
server.exe 127.0.0.1 4242 1
client.exe 127.0.0.1 4242 "Hello"
If everything works I believe it should print "Hello" on server command prompt
Below is the code
void
on_read(
beast::error_code ec,
std::size_t bytes_transferred)
{
boost::ignore_unused(bytes_transferred);
// This indicates that the session was closed
if (ec == websocket::error::closed)
return;
if (ec)
fail(ec, "read");
// Echo the message
ws_.text(ws_.got_text());
std::cout << "writing received value " << std::endl;
ws_.async_write(
buffer_.data(),
beast::bind_front_handler(
&session::on_write,
shared_from_this()));
std::cout << buffer_.data().data()<< std::endl;
}
ws_.write() is not writing anything on console , however buffer_data.data() renders
00000163E044EE80
How do I make sure this is working fine? How do I retrieve string value from the socket buffer?