简体   繁体   English

我不明白为什么boost :: asio :: read_until读取分隔符后面的字符

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

According to the boost::asio::read_until documentation: 根据boost::asio::read_until文档:

After a successful read_until operation, the streambuf may contain additional data beyond the delimiter. 成功完成read_until操作后,streambuf可能包含定界符之外的其他数据。 An application will typically leave that data in the streambuf for a subsequent read_until operation to examine. 应用程序通常会将这些数据保留在streambuf中,以供后续的read_until操作进行检查。

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? 是因为在TCP协议中,如果您不阅读所有可用字符,会丢失它们吗?

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. 这将是非常低效的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM