boost::asio::ip::tcp::socket
有两种读取流的函数。我假设他们的语义不同。有人可以概述一下吗,我有文档 looked through没有澄清这一点。
最佳答案
正如文档中所说:
The
receive()
operation may not receive all of the requested number of bytes. Consider using theread()
function if you need to ensure that the requested amount of data is read before the blocking operation completes.
如果您实际上是指 read_some()
,则没有区别。 receive()
是特定于套接字的函数,而 read_some()
是可用于所有 asio 流的通用函数。 (很像 std::string
的 length()
和 size()
)
关于c++ - 提升 asio receive() 与 read(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6733425/