server
Код: Выделить всё
void Session::send_id(const std::string& jsonMessageID_)
{
auto self(shared_from_this());
uint32_t data_size = static_cast(jsonMessageID_.size());
uint32_t network_data_size = htonl(data_size);
std::vector buffer(sizeof(network_data_size) + jsonMessageID_.size());
std::memcpy(buffer.data(), &network_data_size, sizeof(network_data_size));
std::memcpy(buffer.data() + sizeof(network_data_size), jsonMessageID_.data(), jsonMessageID_.size());
boost::asio::async_write(socket_, boost::asio::buffer(buffer), [this, self](const boost::system::error_code ec_, std::size_t bytes_transferred) {
if (ec_) {
BOOST_LOG_TRIVIAL(error) bytesAvailable() < nextBlockSize_)
{
break;
}
QString str_;
in >> str_;
qDebug()
Подробнее здесь: [url]https://stackoverflow.com/questions/79413438/i-cant-get-a-response-from-the-c-boost-server-to-the-c-qt-client[/url]