简体   繁体   中英

boost asio receive() vs read()

There are two types of reading-from-stream functions 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() )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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