Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

boost::asio::async_write() versus boost::asio::write()

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

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

instead of

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));
like image 644
Al Kurlansky Avatar asked Jan 18 '12 14:01

Al Kurlansky


1 Answers

The big difference is that the normal write can block until all is written, while async_write returns immediately and calls a callback when either all data is written or an error occurs.

I doubt there is any noticeable difference in time from call to the data actually being sent over the wire.

like image 123
Some programmer dude Avatar answered Sep 16 '22 19:09

Some programmer dude