Boost :: asio :: async_write () vs boost :: asio :: write ()

Is there any advantage in terms of the time it takes to get the data buffer on the wire if you use

boost::asio::write(m_socket, asio::buffer(dataOut_, len), asio::transfer_all()); 

instead

 boost::asio::async_write(m_socket, boost::asio::buffer(hbs, sizeof(hbs)), boost::bind(&Client::handle_pulse, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); 
+7
source share
1 answer

The big difference is that a normal write can be blocked until everything is written, and async_write will immediately return and call a callback when either all the data is written or an error occurs.

I doubt that there is a noticeable time difference from the call to the actual data transmitted over the wire.

+2
source

All Articles