I am new to boost library. I am writing a WebSocket server. But facing a problem that when I send a message to a client 2 messages concatenate like first I send "Hello" and then "World". but the client received "HelloWorld". I am attaching my code as a zip file. To handle this I have done this kind of change in code:
beast::flat_buffer m_WriteBuffer;
boost::beast::ostream(m_WriteBuffer) << message;
ws_.async_write(m_WriteBuffer.data(),
beast::bind_front_handler(
&WebSocketSession::on_write,
shared_from_this()));
Sleep(100);
I have added the sleep after the send then it works fine. I have also used option TCP NO_Delay but still, the issue is there.
Declaration:
boost::asio::io_context g_ioc{ 10 };
ssl::context g_ctx{ ssl::context::tlsv12 };
tcp::acceptor g_acceptor(net::make_strand(g_ioc));`
g_acceptor.set_option(tcp::no_delay(true), ec);
if (ec)
{
stl::log::trace(stl::log::LOG_GROUP_ERROR, stl::log::LOG_LEVEL_ERROR, "WebSocketListener::WebSocketListener set_option(No delay) failed, error message: %s", ec.message().c_str());
return;
}
My code on github
how can I solve this?