开发者

boost asio receive() vs read()

There are two types of reading-from-stream f开发者_开发技巧unctions for boost::asio::ip::tcp::socket. I am assuming they their semantics vary. Could someone please outline them, the documentation I have looked through does not clarrify this.


As it says in the documentation:

The receive() operation may not receive all of the requested number of bytes. Consider using the read() function if you need to ensure that the requested amount of data is read before the blocking operation completes.

If you actually meant read_some(), then there is no difference. receive() is the socket-specific function, whereas read_some() is the generic function available for all asio streams. (much like std::string's length() and size())

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜