Boost logo

Boost Users :

From: Pavel Vazharov (freakpv_at_[hidden])
Date: 2024-03-06 14:36:26


Hi,

The most obvious error that I see is that you use `std::vector<char>
buffer_data(1024);`as local variables and then they are destroyed but you
continue to keep references to them via the boost::asio::buffer.
The latter will not keep the `std::vector`s alive.
You need to keep the std::vector as a member variable and only when you
call the asio functions use the `boost::asio::buffer` function.
Like
m_socketHandler->socket.async_read_some(boost::asio::buffer(m_buffer_data),
...

Where the m_buffer_data is a member variable of type `std::vector<char>`.

HTH,
Pavel.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net