Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between asio::tcp::socket's async_read_some and async_receive?

Tags:

c++

boost-asio

What is the difference between:

  • boost::asio::tcp::socket::async_read_some()
  • boost::asio::tcp::socket::async_receive()

As far as I can tell their documentation is identical.

Which should I prefer?

like image 406
deft_code Avatar asked Feb 10 '10 15:02

deft_code


1 Answers

I believe the two are essentially identical. The reason they provide both is to provide interfaces similar to both iostreams (which have a read_some member) and sockets (which have a receive).

As Peter Tseng pointed out, async_receive does also have an overload that accepts socket_base::message_flags, which async_read_some does not.

like image 70
Jerry Coffin Avatar answered Oct 12 '22 19:10

Jerry Coffin