Use synchronous writes in chunk output example

This commit is contained in:
Vinnie Falco
2017-10-25 22:55:56 -07:00
parent 2555942010
commit 3d3bc87042
2 changed files with 4 additions and 19 deletions

View File

@ -6,6 +6,7 @@ HTTP:
* Add message::need_eof * Add message::need_eof
* Use message::need_eof in example servers * Use message::need_eof in example servers
* Use synchronous writes in chunk output example
API Changes: API Changes:

View File

@ -180,34 +180,18 @@ void fxx() {
// Write the next chunk with the chunk extensions // Write the next chunk with the chunk extensions
// The implementation will make a copy of the extensions object, // The implementation will make a copy of the extensions object,
// so the caller does not need to manage lifetime issues. // so the caller does not need to manage lifetime issues.
boost::asio::async_write(sock, make_chunk(get_next_chunk_body(), ext), boost::asio::write(sock, make_chunk(get_next_chunk_body(), ext));
[](error_code ec, std::size_t)
{
if(ec)
std::cout << "Error: " << ec.message() << std::endl;
});
// Write the next chunk with the chunk extensions // Write the next chunk with the chunk extensions
// The implementation will make a copy of the extensions object, storing the copy // The implementation will make a copy of the extensions object, storing the copy
// using the custom allocator, so the caller does not need to manage lifetime issues. // using the custom allocator, so the caller does not need to manage lifetime issues.
boost::asio::async_write(sock, boost::asio::write(sock, make_chunk(get_next_chunk_body(), ext, std::allocator<char>{}));
make_chunk(get_next_chunk_body(), ext, std::allocator<char>{}),
[](error_code ec, std::size_t)
{
if(ec)
std::cout << "Error: " << ec.message() << std::endl;
});
// Write the next chunk with the chunk extensions // Write the next chunk with the chunk extensions
// The implementation allocates memory using the default allocator and takes ownership // The implementation allocates memory using the default allocator and takes ownership
// of the extensions object, so the caller does not need to manage lifetime issues. // of the extensions object, so the caller does not need to manage lifetime issues.
// Note: ext is moved // Note: ext is moved
boost::asio::async_write(sock, make_chunk(get_next_chunk_body(), std::move(ext)), boost::asio::write(sock, make_chunk(get_next_chunk_body(), std::move(ext)));
[](error_code ec, std::size_t)
{
if(ec)
std::cout << "Error: " << ec.message() << std::endl;
});
//] //]
} }