bugfix: messages would only be received till the first whitespace

This commit is contained in:
Kjistóf 2016-11-20 11:14:20 +01:00
parent 41f81518c2
commit 4215343175

View File

@ -8,8 +8,7 @@ void message::send(boost::asio::ip::tcp::socket& socket)
{
system::error_code ec;
asio::write(socket, asio::buffer(get_message_length()), ec);
asio::write(socket, asio::buffer(get_message()), ec);
asio::write(socket, asio::buffer(get_message_length() + get_message()), ec);
if (ec)
throw std::runtime_error("Networking error: " + ec.message());
@ -28,8 +27,9 @@ void message::receive(boost::asio::ip::tcp::socket& socket)
asio::read(socket, sb, asio::transfer_exactly(len), ec);
data.clear();
data.reserve(len);
is.clear();
is >> data;
data = std::string(std::istreambuf_iterator<char>(is), std::istreambuf_iterator<char>());
if (ec)
throw std::runtime_error("Networking error: " + ec.message());