I’m developing a tcp client using boost::asio to process incoming text, that ends with “\n”. However, when I am sending text containing whitespace, it drops all characters after the first whitespace appears. I’ve already verified that the text I’m sending is complete.
This is my code:
boost::system::error_code error;
boost::asio::streambuf buffer;
boost::asio::read_until( *socket, buffer, "\n", error );
std::istream str(&buffer);
std::string s;
str >> s;
Use
std::getlineinstead of>>, which is what stops reading on encountering whitespace: