Martel
Martel

Reputation: 2734

I don't understand why boost::asio::read_until reads characters behind the delimiter

According to the boost::asio::read_until documentation:

After a successful read_until operation, the streambuf may contain additional data beyond the delimiter. An application will typically leave that data in the streambuf for a subsequent read_until operation to examine.

I do not understand why this happens.

Is it because, in the TCP protocol, if you do not read all the available characters, you can lose them?

Upvotes: 0

Views: 243

Answers (1)

Richard Hodges
Richard Hodges

Reputation: 69892

Because if it read only until the character you want, it would have to perform one one-character read at a time. This would be horribly inefficient.

Upvotes: 1

Related Questions