Boost logo

Boost Users :

Subject: [Boost-users] boost::asio::read_until reads too much!
From: Rob Currey (avalonforest_at_[hidden])
Date: 2009-02-20 19:18:41


executing this code:
        boost::asio::streambuf b;
std::cout << "socket.available()=" << socket.available() << std::endl;
        size_t received = boost::asio::read_until(socket, b, "\r\n");
std::cout << "received=" << received << std::endl;
std::cout << "b.size()=" << b.size() << std::endl;
        std::istream is(&b);
        std::getline(is, m_token);

results in output of:

socket.available()=34
received=26
b.size()=34

In my app I need to read the 8 bytes (after the 26) as binary (and hence don't use the streambuf to do so).
Yet read_until has already consumed them from the socket and placed them in the streambuf :(

Suggestions?



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