c++ - 我不明白为什么 boost::asio::read_until 读取定界符后面的字符

标签 c++ boost tcp

根据 boost::asio::read_until 文档:

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.

我不明白为什么会这样。

是不是因为在 TCP 协议(protocol)中,如果不读取所有可用字符,就会丢失它们?

最佳答案

因为如果它只读到你想要的字符,它就必须一次读取一个字符。这将是非常低效的。

关于c++ - 我不明白为什么 boost::asio::read_until 读取定界符后面的字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45376498/

相关文章:

c - c中的linux TCP多客户端回显服务器

c++ - 更改数据忽略 const 限定符

c# - 位移位是否总是考虑 Endian 体系结构?

C++:进入EOF后cin流的condition状态能否恢复

c++ - 是否可以在 Allegro5 中使用系统字体?

c++ - 作用域指针和重置

c++ - Boost 无法从演示中找到 future::then

c++ - 在运行时 boost 异常

java - 当 Activity 发生变化时,如何保持与服务器的 TCP 连接?

c++ - 什么是简单的 C 或 C++ TCP 服务器和客户端示例?