]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/asio/test/write.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / asio / test / write.cpp
index d9b6172445f04ed8c6978bcbc521691fb0b2f230..0e68e82e60755d08aaed0cdddbdedc7e0f42761e 100644 (file)
@@ -2,7 +2,7 @@
 // write.cpp
 // ~~~~~~~~~
 //
-// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
 //
 // Distributed under the Boost Software License, Version 1.0. (See accompanying
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -19,7 +19,8 @@
 #include <cstring>
 #include <vector>
 #include "archetypes/async_result.hpp"
-#include <boost/asio/io_service.hpp>
+#include <boost/asio/io_context.hpp>
+#include <boost/asio/post.hpp>
 #include <boost/asio/streambuf.hpp>
 #include "unit_test.hpp"
 
@@ -42,10 +43,10 @@ using namespace std; // For memcmp, memcpy and memset.
 class test_stream
 {
 public:
-  typedef boost::asio::io_service io_service_type;
+  typedef boost::asio::io_context::executor_type executor_type;
 
-  test_stream(boost::asio::io_service& io_service)
-    : io_service_(io_service),
+  test_stream(boost::asio::io_context& io_context)
+    : io_context_(io_context),
       length_(max_length),
       position_(0),
       next_write_length_(max_length)
@@ -53,9 +54,9 @@ public:
     memset(data_, 0, max_length);
   }
 
-  io_service_type& get_io_service()
+  executor_type get_executor() BOOST_ASIO_NOEXCEPT
   {
-    return io_service_;
+    return io_context_.get_executor();
   }
 
   void reset(size_t length = max_length)
@@ -73,22 +74,20 @@ public:
     next_write_length_ = length;
   }
 
-  template <typename Const_Buffers>
-  bool check_buffers(const Const_Buffers& buffers, size_t length)
+  template <typename Iterator>
+  bool check_buffers(Iterator begin, Iterator end, size_t length)
   {
     if (length != position_)
       return false;
 
-    typename Const_Buffers::const_iterator iter = buffers.begin();
-    typename Const_Buffers::const_iterator end = buffers.end();
+    Iterator iter = begin;
     size_t checked_length = 0;
     for (; iter != end && checked_length < length; ++iter)
     {
       size_t buffer_length = boost::asio::buffer_size(*iter);
       if (buffer_length > length - checked_length)
         buffer_length = length - checked_length;
-      if (memcmp(data_ + checked_length,
-            boost::asio::buffer_cast<const void*>(*iter), buffer_length) != 0)
+      if (memcmp(data_ + checked_length, iter->data(), buffer_length) != 0)
         return false;
       checked_length += buffer_length;
     }
@@ -96,6 +95,13 @@ public:
     return true;
   }
 
+  template <typename Const_Buffers>
+  bool check_buffers(const Const_Buffers& buffers, size_t length)
+  {
+    return check_buffers(boost::asio::buffer_sequence_begin(buffers),
+        boost::asio::buffer_sequence_end(buffers), length);
+  }
+
   template <typename Const_Buffers>
   size_t write_some(const Const_Buffers& buffers)
   {
@@ -117,12 +123,14 @@ public:
   void async_write_some(const Const_Buffers& buffers, Handler handler)
   {
     size_t bytes_transferred = write_some(buffers);
-    io_service_.post(boost::asio::detail::bind_handler(
-          handler, boost::system::error_code(), bytes_transferred));
+    boost::asio::post(get_executor(),
+        boost::asio::detail::bind_handler(
+          BOOST_ASIO_MOVE_CAST(Handler)(handler),
+          boost::system::error_code(), bytes_transferred));
   }
 
 private:
-  io_service_type& io_service_;
+  boost::asio::io_context& io_context_;
   enum { max_length = 8192 };
   char data_[max_length];
   size_t length_;
@@ -137,19 +145,19 @@ static char mutable_write_data[]
 
 void test_2_arg_zero_buffers_write()
 {
-  boost::asio::io_service ios;
-  test_stream s(ios);
+  boost::asio::io_context ioc;
+  test_stream s(ioc);
   std::vector<boost::asio::const_buffer> buffers;
 
   size_t bytes_transferred = boost::asio::write(s, buffers);
   BOOST_ASIO_CHECK(bytes_transferred == 0);
 }
 
-void test_2_arg_const_buffers_1_write()
+void test_2_arg_const_buffer_write()
 {
-  boost::asio::io_service ios;
-  test_stream s(ios);
-  boost::asio::const_buffers_1 buffers
+  boost::asio::io_context ioc;
+  test_stream s(ioc);
+  boost::asio::const_buffer buffers
     = boost::asio::buffer(write_data, sizeof(write_data));
 
   s.reset();
@@ -170,11 +178,11 @@ void test_2_arg_const_buffers_1_write()
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 }
 
-void test_2_arg_mutable_buffers_1_write()
+void test_2_arg_mutable_buffer_write()
 {
-  boost::asio::io_service ios;
-  test_stream s(ios);
-  boost::asio::mutable_buffers_1 buffers
+  boost::asio::io_context ioc;
+  test_stream s(ioc);
+  boost::asio::mutable_buffer buffers
     = boost::asio::buffer(mutable_write_data, sizeof(mutable_write_data));
 
   s.reset();
@@ -197,11 +205,12 @@ void test_2_arg_mutable_buffers_1_write()
 
 void test_2_arg_vector_buffers_write()
 {
-  boost::asio::io_service ios;
-  test_stream s(ios);
+  boost::asio::io_context ioc;
+  test_stream s(ioc);
   std::vector<boost::asio::const_buffer> buffers;
   buffers.push_back(boost::asio::buffer(write_data, 32));
-  buffers.push_back(boost::asio::buffer(write_data) + 32);
+  buffers.push_back(boost::asio::buffer(write_data, 39) + 32);
+  buffers.push_back(boost::asio::buffer(write_data) + 39);
 
   s.reset();
   size_t bytes_transferred = boost::asio::write(s, buffers);
@@ -223,8 +232,8 @@ void test_2_arg_vector_buffers_write()
 
 void test_3_arg_nothrow_zero_buffers_write()
 {
-  boost::asio::io_service ios;
-  test_stream s(ios);
+  boost::asio::io_context ioc;
+  test_stream s(ioc);
   std::vector<boost::asio::const_buffer> buffers;
 
   boost::system::error_code error;
@@ -233,11 +242,11 @@ void test_3_arg_nothrow_zero_buffers_write()
   BOOST_ASIO_CHECK(!error);
 }
 
-void test_3_arg_nothrow_const_buffers_1_write()
+void test_3_arg_nothrow_const_buffer_write()
 {
-  boost::asio::io_service ios;
-  test_stream s(ios);
-  boost::asio::const_buffers_1 buffers
+  boost::asio::io_context ioc;
+  test_stream s(ioc);
+  boost::asio::const_buffer buffers
     = boost::asio::buffer(write_data, sizeof(write_data));
 
   s.reset();
@@ -262,11 +271,11 @@ void test_3_arg_nothrow_const_buffers_1_write()
   BOOST_ASIO_CHECK(!error);
 }
 
-void test_3_arg_nothrow_mutable_buffers_1_write()
+void test_3_arg_nothrow_mutable_buffer_write()
 {
-  boost::asio::io_service ios;
-  test_stream s(ios);
-  boost::asio::mutable_buffers_1 buffers
+  boost::asio::io_context ioc;
+  test_stream s(ioc);
+  boost::asio::mutable_buffer buffers
     = boost::asio::buffer(mutable_write_data, sizeof(mutable_write_data));
 
   s.reset();
@@ -293,11 +302,12 @@ void test_3_arg_nothrow_mutable_buffers_1_write()
 
 void test_3_arg_nothrow_vector_buffers_write()
 {
-  boost::asio::io_service ios;
-  test_stream s(ios);
+  boost::asio::io_context ioc;
+  test_stream s(ioc);
   std::vector<boost::asio::const_buffer> buffers;
   buffers.push_back(boost::asio::buffer(write_data, 32));
-  buffers.push_back(boost::asio::buffer(write_data) + 32);
+  buffers.push_back(boost::asio::buffer(write_data, 39) + 32);
+  buffers.push_back(boost::asio::buffer(write_data) + 39);
 
   s.reset();
   boost::system::error_code error;
@@ -333,11 +343,11 @@ size_t short_transfer(const boost::system::error_code& ec,
   return !!ec ? 0 : 3;
 }
 
-void test_3_arg_const_buffers_1_write()
+void test_3_arg_const_buffer_write()
 {
-  boost::asio::io_service ios;
-  test_stream s(ios);
-  boost::asio::const_buffers_1 buffers
+  boost::asio::io_context ioc;
+  test_stream s(ioc);
+  boost::asio::const_buffer buffers
     = boost::asio::buffer(write_data, sizeof(write_data));
 
   s.reset();
@@ -515,11 +525,11 @@ void test_3_arg_const_buffers_1_write()
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 }
 
-void test_3_arg_mutable_buffers_1_write()
+void test_3_arg_mutable_buffer_write()
 {
-  boost::asio::io_service ios;
-  test_stream s(ios);
-  boost::asio::mutable_buffers_1 buffers
+  boost::asio::io_context ioc;
+  test_stream s(ioc);
+  boost::asio::mutable_buffer buffers
     = boost::asio::buffer(mutable_write_data, sizeof(mutable_write_data));
 
   s.reset();
@@ -699,11 +709,12 @@ void test_3_arg_mutable_buffers_1_write()
 
 void test_3_arg_vector_buffers_write()
 {
-  boost::asio::io_service ios;
-  test_stream s(ios);
+  boost::asio::io_context ioc;
+  test_stream s(ioc);
   std::vector<boost::asio::const_buffer> buffers;
   buffers.push_back(boost::asio::buffer(write_data, 32));
-  buffers.push_back(boost::asio::buffer(write_data) + 32);
+  buffers.push_back(boost::asio::buffer(write_data, 39) + 32);
+  buffers.push_back(boost::asio::buffer(write_data) + 39);
 
   s.reset();
   size_t bytes_transferred = boost::asio::write(s, buffers,
@@ -880,11 +891,11 @@ void test_3_arg_vector_buffers_write()
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 }
 
-void test_4_arg_const_buffers_1_write()
+void test_4_arg_const_buffer_write()
 {
-  boost::asio::io_service ios;
-  test_stream s(ios);
-  boost::asio::const_buffers_1 buffers
+  boost::asio::io_context ioc;
+  test_stream s(ioc);
+  boost::asio::const_buffer buffers
     = boost::asio::buffer(write_data, sizeof(write_data));
 
   s.reset();
@@ -1117,11 +1128,11 @@ void test_4_arg_const_buffers_1_write()
   BOOST_ASIO_CHECK(!error);
 }
 
-void test_4_arg_mutable_buffers_1_write()
+void test_4_arg_mutable_buffer_write()
 {
-  boost::asio::io_service ios;
-  test_stream s(ios);
-  boost::asio::mutable_buffers_1 buffers
+  boost::asio::io_context ioc;
+  test_stream s(ioc);
+  boost::asio::mutable_buffer buffers
     = boost::asio::buffer(mutable_write_data, sizeof(mutable_write_data));
 
   s.reset();
@@ -1356,11 +1367,12 @@ void test_4_arg_mutable_buffers_1_write()
 
 void test_4_arg_vector_buffers_write()
 {
-  boost::asio::io_service ios;
-  test_stream s(ios);
+  boost::asio::io_context ioc;
+  test_stream s(ioc);
   std::vector<boost::asio::const_buffer> buffers;
   buffers.push_back(boost::asio::buffer(write_data, 32));
-  buffers.push_back(boost::asio::buffer(write_data) + 32);
+  buffers.push_back(boost::asio::buffer(write_data, 39) + 32);
+  buffers.push_back(boost::asio::buffer(write_data) + 39);
 
   s.reset();
   boost::system::error_code error;
@@ -1600,7 +1612,7 @@ void async_write_handler(const boost::system::error_code& e,
   BOOST_ASIO_CHECK(bytes_transferred == expected_bytes_transferred);
 }
 
-void test_3_arg_const_buffers_1_async_write()
+void test_3_arg_const_buffer_async_write()
 {
 #if defined(BOOST_ASIO_HAS_BOOST_BIND)
   namespace bindns = boost;
@@ -1610,9 +1622,9 @@ void test_3_arg_const_buffers_1_async_write()
   using std::placeholders::_2;
 #endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
 
-  boost::asio::io_service ios;
-  test_stream s(ios);
-  boost::asio::const_buffers_1 buffers
+  boost::asio::io_context ioc;
+  test_stream s(ioc);
+  boost::asio::const_buffer buffers
     = boost::asio::buffer(write_data, sizeof(write_data));
 
   s.reset();
@@ -1620,8 +1632,8 @@ void test_3_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -1631,8 +1643,8 @@ void test_3_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -1642,20 +1654,20 @@ void test_3_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
   s.reset();
   int i = boost::asio::async_write(s, buffers, archetypes::lazy_handler());
   BOOST_ASIO_CHECK(i == 42);
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 }
 
-void test_3_arg_mutable_buffers_1_async_write()
+void test_3_arg_mutable_buffer_async_write()
 {
 #if defined(BOOST_ASIO_HAS_BOOST_BIND)
   namespace bindns = boost;
@@ -1665,9 +1677,9 @@ void test_3_arg_mutable_buffers_1_async_write()
   using std::placeholders::_2;
 #endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
 
-  boost::asio::io_service ios;
-  test_stream s(ios);
-  boost::asio::mutable_buffers_1 buffers
+  boost::asio::io_context ioc;
+  test_stream s(ioc);
+  boost::asio::mutable_buffer buffers
     = boost::asio::buffer(mutable_write_data, sizeof(mutable_write_data));
 
   s.reset();
@@ -1675,8 +1687,8 @@ void test_3_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(mutable_write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
 
@@ -1686,8 +1698,8 @@ void test_3_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(mutable_write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
 
@@ -1697,16 +1709,16 @@ void test_3_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(mutable_write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
 
   s.reset();
   int i = boost::asio::async_write(s, buffers, archetypes::lazy_handler());
   BOOST_ASIO_CHECK(i == 42);
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
 }
 
@@ -1721,8 +1733,8 @@ void test_3_arg_boost_array_buffers_async_write()
 #endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
 
 #if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
-  boost::asio::io_service ios;
-  test_stream s(ios);
+  boost::asio::io_context ioc;
+  test_stream s(ioc);
   boost::array<boost::asio::const_buffer, 2> buffers = { {
     boost::asio::buffer(write_data, 32),
     boost::asio::buffer(write_data) + 32 } };
@@ -1732,8 +1744,8 @@ void test_3_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -1743,8 +1755,8 @@ void test_3_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -1754,16 +1766,16 @@ void test_3_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
   s.reset();
   int i = boost::asio::async_write(s, buffers, archetypes::lazy_handler());
   BOOST_ASIO_CHECK(i == 42);
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 #endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
 }
@@ -1779,8 +1791,8 @@ void test_3_arg_std_array_buffers_async_write()
 #endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
 
 #if defined(BOOST_ASIO_HAS_STD_ARRAY)
-  boost::asio::io_service ios;
-  test_stream s(ios);
+  boost::asio::io_context ioc;
+  test_stream s(ioc);
   std::array<boost::asio::const_buffer, 2> buffers = { {
     boost::asio::buffer(write_data, 32),
     boost::asio::buffer(write_data) + 32 } };
@@ -1790,8 +1802,8 @@ void test_3_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -1801,8 +1813,8 @@ void test_3_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -1812,16 +1824,16 @@ void test_3_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
   s.reset();
   int i = boost::asio::async_write(s, buffers, archetypes::lazy_handler());
   BOOST_ASIO_CHECK(i == 42);
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 #endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
 }
@@ -1836,19 +1848,20 @@ void test_3_arg_vector_buffers_async_write()
   using std::placeholders::_2;
 #endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
 
-  boost::asio::io_service ios;
-  test_stream s(ios);
+  boost::asio::io_context ioc;
+  test_stream s(ioc);
   std::vector<boost::asio::const_buffer> buffers;
   buffers.push_back(boost::asio::buffer(write_data, 32));
-  buffers.push_back(boost::asio::buffer(write_data) + 32);
+  buffers.push_back(boost::asio::buffer(write_data, 39) + 32);
+  buffers.push_back(boost::asio::buffer(write_data) + 39);
 
   s.reset();
   bool called = false;
   boost::asio::async_write(s, buffers,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -1858,8 +1871,8 @@ void test_3_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -1869,16 +1882,16 @@ void test_3_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
   s.reset();
   int i = boost::asio::async_write(s, buffers, archetypes::lazy_handler());
   BOOST_ASIO_CHECK(i == 42);
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 }
 
@@ -1892,10 +1905,10 @@ void test_3_arg_streambuf_async_write()
   using std::placeholders::_2;
 #endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
 
-  boost::asio::io_service ios;
-  test_stream s(ios);
+  boost::asio::io_context ioc;
+  test_stream s(ioc);
   boost::asio::streambuf sb;
-  boost::asio::const_buffers_1 buffers
+  boost::asio::const_buffer buffers
     = boost::asio::buffer(write_data, sizeof(write_data));
 
   s.reset();
@@ -1905,8 +1918,8 @@ void test_3_arg_streambuf_async_write()
   boost::asio::async_write(s, sb,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -1918,8 +1931,8 @@ void test_3_arg_streambuf_async_write()
   boost::asio::async_write(s, sb,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -1931,8 +1944,8 @@ void test_3_arg_streambuf_async_write()
   boost::asio::async_write(s, sb,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -1941,12 +1954,12 @@ void test_3_arg_streambuf_async_write()
   sb.sputn(write_data, sizeof(write_data));
   int i = boost::asio::async_write(s, sb, archetypes::lazy_handler());
   BOOST_ASIO_CHECK(i == 42);
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 }
 
-void test_4_arg_const_buffers_1_async_write()
+void test_4_arg_const_buffer_async_write()
 {
 #if defined(BOOST_ASIO_HAS_BOOST_BIND)
   namespace bindns = boost;
@@ -1956,9 +1969,9 @@ void test_4_arg_const_buffers_1_async_write()
   using std::placeholders::_2;
 #endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
 
-  boost::asio::io_service ios;
-  test_stream s(ios);
-  boost::asio::const_buffers_1 buffers
+  boost::asio::io_context ioc;
+  test_stream s(ioc);
+  boost::asio::const_buffer buffers
     = boost::asio::buffer(write_data, sizeof(write_data));
 
   s.reset();
@@ -1966,8 +1979,8 @@ void test_4_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -1977,8 +1990,8 @@ void test_4_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -1988,8 +2001,8 @@ void test_4_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -1998,8 +2011,8 @@ void test_4_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -2009,8 +2022,8 @@ void test_4_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
       bindns::bind(async_write_handler,
         _1, _2, 1, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
 
@@ -2020,8 +2033,8 @@ void test_4_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -2030,8 +2043,8 @@ void test_4_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -2041,8 +2054,8 @@ void test_4_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -2052,8 +2065,8 @@ void test_4_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -2062,8 +2075,8 @@ void test_4_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -2073,8 +2086,8 @@ void test_4_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
       bindns::bind(async_write_handler,
         _1, _2, 42, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
 
@@ -2084,8 +2097,8 @@ void test_4_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
       bindns::bind(async_write_handler,
         _1, _2, 50, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
 
@@ -2094,8 +2107,8 @@ void test_4_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
       bindns::bind(async_write_handler,
         _1, _2, 1, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
 
@@ -2105,8 +2118,8 @@ void test_4_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
       bindns::bind(async_write_handler,
         _1, _2, 1, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
 
@@ -2116,8 +2129,8 @@ void test_4_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
       bindns::bind(async_write_handler,
         _1, _2, 1, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
 
@@ -2126,8 +2139,8 @@ void test_4_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -2137,8 +2150,8 @@ void test_4_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -2148,8 +2161,8 @@ void test_4_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -2158,8 +2171,8 @@ void test_4_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
       bindns::bind(async_write_handler,
         _1, _2, 42, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
 
@@ -2169,8 +2182,8 @@ void test_4_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
       bindns::bind(async_write_handler,
         _1, _2, 42, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
 
@@ -2180,8 +2193,8 @@ void test_4_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
       bindns::bind(async_write_handler,
         _1, _2, 42, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
 
@@ -2190,8 +2203,8 @@ void test_4_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers, old_style_transfer_all,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -2201,8 +2214,8 @@ void test_4_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers, old_style_transfer_all,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -2212,8 +2225,8 @@ void test_4_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers, old_style_transfer_all,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -2222,8 +2235,8 @@ void test_4_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers, short_transfer,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -2233,8 +2246,8 @@ void test_4_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers, short_transfer,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -2244,8 +2257,8 @@ void test_4_arg_const_buffers_1_async_write()
   boost::asio::async_write(s, buffers, short_transfer,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -2253,12 +2266,12 @@ void test_4_arg_const_buffers_1_async_write()
   int i = boost::asio::async_write(s, buffers, short_transfer,
       archetypes::lazy_handler());
   BOOST_ASIO_CHECK(i == 42);
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 }
 
-void test_4_arg_mutable_buffers_1_async_write()
+void test_4_arg_mutable_buffer_async_write()
 {
 #if defined(BOOST_ASIO_HAS_BOOST_BIND)
   namespace bindns = boost;
@@ -2268,9 +2281,9 @@ void test_4_arg_mutable_buffers_1_async_write()
   using std::placeholders::_2;
 #endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
 
-  boost::asio::io_service ios;
-  test_stream s(ios);
-  boost::asio::mutable_buffers_1 buffers
+  boost::asio::io_context ioc;
+  test_stream s(ioc);
+  boost::asio::mutable_buffer buffers
     = boost::asio::buffer(mutable_write_data, sizeof(mutable_write_data));
 
   s.reset();
@@ -2278,8 +2291,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(mutable_write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
 
@@ -2289,8 +2302,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(mutable_write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
 
@@ -2300,8 +2313,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(mutable_write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
 
@@ -2310,8 +2323,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(mutable_write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
 
@@ -2321,8 +2334,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
       bindns::bind(async_write_handler,
         _1, _2, 1, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
 
@@ -2332,8 +2345,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -2342,8 +2355,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(mutable_write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
 
@@ -2353,8 +2366,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -2364,8 +2377,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -2374,8 +2387,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(mutable_write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
 
@@ -2385,8 +2398,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
       bindns::bind(async_write_handler,
         _1, _2, 42, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
 
@@ -2396,8 +2409,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
       bindns::bind(async_write_handler,
         _1, _2, 50, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
 
@@ -2406,8 +2419,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
       bindns::bind(async_write_handler,
         _1, _2, 1, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
 
@@ -2417,8 +2430,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
       bindns::bind(async_write_handler,
         _1, _2, 1, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
 
@@ -2428,8 +2441,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
       bindns::bind(async_write_handler,
         _1, _2, 1, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
 
@@ -2438,8 +2451,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -2449,8 +2462,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -2460,8 +2473,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -2470,8 +2483,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
       bindns::bind(async_write_handler,
         _1, _2, 42, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
 
@@ -2481,8 +2494,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
       bindns::bind(async_write_handler,
         _1, _2, 42, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
 
@@ -2492,8 +2505,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
       bindns::bind(async_write_handler,
         _1, _2, 42, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
 
@@ -2502,8 +2515,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers, old_style_transfer_all,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(mutable_write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
 
@@ -2513,8 +2526,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers, old_style_transfer_all,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(mutable_write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
 
@@ -2524,8 +2537,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers, old_style_transfer_all,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(mutable_write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
 
@@ -2534,8 +2547,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers, short_transfer,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(mutable_write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
 
@@ -2545,8 +2558,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers, short_transfer,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(mutable_write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
 
@@ -2556,8 +2569,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   boost::asio::async_write(s, buffers, short_transfer,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(mutable_write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
 
@@ -2565,8 +2578,8 @@ void test_4_arg_mutable_buffers_1_async_write()
   int i = boost::asio::async_write(s, buffers, short_transfer,
       archetypes::lazy_handler());
   BOOST_ASIO_CHECK(i == 42);
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 }
 
@@ -2581,8 +2594,8 @@ void test_4_arg_boost_array_buffers_async_write()
 #endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
 
 #if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
-  boost::asio::io_service ios;
-  test_stream s(ios);
+  boost::asio::io_context ioc;
+  test_stream s(ioc);
   boost::array<boost::asio::const_buffer, 2> buffers = { {
     boost::asio::buffer(write_data, 32),
     boost::asio::buffer(write_data) + 32 } };
@@ -2592,8 +2605,8 @@ void test_4_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -2603,8 +2616,8 @@ void test_4_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -2614,8 +2627,8 @@ void test_4_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -2624,8 +2637,8 @@ void test_4_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -2635,8 +2648,8 @@ void test_4_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
       bindns::bind(async_write_handler,
         _1, _2, 1, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
 
@@ -2646,8 +2659,8 @@ void test_4_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -2656,8 +2669,8 @@ void test_4_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -2667,8 +2680,8 @@ void test_4_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -2678,8 +2691,8 @@ void test_4_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -2688,8 +2701,8 @@ void test_4_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -2699,8 +2712,8 @@ void test_4_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
       bindns::bind(async_write_handler,
         _1, _2, 42, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
 
@@ -2710,8 +2723,8 @@ void test_4_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
       bindns::bind(async_write_handler,
         _1, _2, 50, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
 
@@ -2720,8 +2733,8 @@ void test_4_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
       bindns::bind(async_write_handler,
         _1, _2, 1, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
 
@@ -2731,8 +2744,8 @@ void test_4_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
       bindns::bind(async_write_handler,
         _1, _2, 1, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
 
@@ -2742,8 +2755,8 @@ void test_4_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
       bindns::bind(async_write_handler,
         _1, _2, 1, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
 
@@ -2752,8 +2765,8 @@ void test_4_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -2763,8 +2776,8 @@ void test_4_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -2774,8 +2787,8 @@ void test_4_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -2784,8 +2797,8 @@ void test_4_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
       bindns::bind(async_write_handler,
         _1, _2, 42, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
 
@@ -2795,8 +2808,8 @@ void test_4_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
       bindns::bind(async_write_handler,
         _1, _2, 42, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
 
@@ -2806,8 +2819,8 @@ void test_4_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
       bindns::bind(async_write_handler,
         _1, _2, 42, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
 
@@ -2816,8 +2829,8 @@ void test_4_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers, old_style_transfer_all,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -2827,8 +2840,8 @@ void test_4_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers, old_style_transfer_all,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -2838,8 +2851,8 @@ void test_4_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers, old_style_transfer_all,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -2848,8 +2861,8 @@ void test_4_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers, short_transfer,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -2859,8 +2872,8 @@ void test_4_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers, short_transfer,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -2870,8 +2883,8 @@ void test_4_arg_boost_array_buffers_async_write()
   boost::asio::async_write(s, buffers, short_transfer,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -2879,8 +2892,8 @@ void test_4_arg_boost_array_buffers_async_write()
   int i = boost::asio::async_write(s, buffers, short_transfer,
       archetypes::lazy_handler());
   BOOST_ASIO_CHECK(i == 42);
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 #endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
 }
@@ -2896,8 +2909,8 @@ void test_4_arg_std_array_buffers_async_write()
 #endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
 
 #if defined(BOOST_ASIO_HAS_STD_ARRAY)
-  boost::asio::io_service ios;
-  test_stream s(ios);
+  boost::asio::io_context ioc;
+  test_stream s(ioc);
   std::array<boost::asio::const_buffer, 2> buffers = { {
     boost::asio::buffer(write_data, 32),
     boost::asio::buffer(write_data) + 32 } };
@@ -2907,8 +2920,8 @@ void test_4_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -2918,8 +2931,8 @@ void test_4_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -2929,8 +2942,8 @@ void test_4_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -2939,8 +2952,8 @@ void test_4_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -2950,8 +2963,8 @@ void test_4_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
       bindns::bind(async_write_handler,
         _1, _2, 1, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
 
@@ -2961,8 +2974,8 @@ void test_4_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -2971,8 +2984,8 @@ void test_4_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -2982,8 +2995,8 @@ void test_4_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -2993,8 +3006,8 @@ void test_4_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -3003,8 +3016,8 @@ void test_4_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3014,8 +3027,8 @@ void test_4_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
       bindns::bind(async_write_handler,
         _1, _2, 42, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
 
@@ -3025,8 +3038,8 @@ void test_4_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
       bindns::bind(async_write_handler,
         _1, _2, 50, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
 
@@ -3035,8 +3048,8 @@ void test_4_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
       bindns::bind(async_write_handler,
         _1, _2, 1, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
 
@@ -3046,8 +3059,8 @@ void test_4_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
       bindns::bind(async_write_handler,
         _1, _2, 1, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
 
@@ -3057,8 +3070,8 @@ void test_4_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
       bindns::bind(async_write_handler,
         _1, _2, 1, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
 
@@ -3067,8 +3080,8 @@ void test_4_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -3078,8 +3091,8 @@ void test_4_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -3089,8 +3102,8 @@ void test_4_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -3099,8 +3112,8 @@ void test_4_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
       bindns::bind(async_write_handler,
         _1, _2, 42, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
 
@@ -3110,8 +3123,8 @@ void test_4_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
       bindns::bind(async_write_handler,
         _1, _2, 42, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
 
@@ -3121,8 +3134,8 @@ void test_4_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
       bindns::bind(async_write_handler,
         _1, _2, 42, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
 
@@ -3131,8 +3144,8 @@ void test_4_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers, old_style_transfer_all,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3142,8 +3155,8 @@ void test_4_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers, old_style_transfer_all,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3153,8 +3166,8 @@ void test_4_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers, old_style_transfer_all,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3163,8 +3176,8 @@ void test_4_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers, short_transfer,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3174,8 +3187,8 @@ void test_4_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers, short_transfer,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3185,8 +3198,8 @@ void test_4_arg_std_array_buffers_async_write()
   boost::asio::async_write(s, buffers, short_transfer,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3194,8 +3207,8 @@ void test_4_arg_std_array_buffers_async_write()
   int i = boost::asio::async_write(s, buffers, short_transfer,
       archetypes::lazy_handler());
   BOOST_ASIO_CHECK(i == 42);
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 #endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
 }
@@ -3210,19 +3223,20 @@ void test_4_arg_vector_buffers_async_write()
   using std::placeholders::_2;
 #endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
 
-  boost::asio::io_service ios;
-  test_stream s(ios);
+  boost::asio::io_context ioc;
+  test_stream s(ioc);
   std::vector<boost::asio::const_buffer> buffers;
   buffers.push_back(boost::asio::buffer(write_data, 32));
-  buffers.push_back(boost::asio::buffer(write_data) + 32);
+  buffers.push_back(boost::asio::buffer(write_data, 39) + 32);
+  buffers.push_back(boost::asio::buffer(write_data) + 39);
 
   s.reset();
   bool called = false;
   boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3232,8 +3246,8 @@ void test_4_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3243,8 +3257,8 @@ void test_4_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_all(),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3253,8 +3267,8 @@ void test_4_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3264,8 +3278,8 @@ void test_4_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
       bindns::bind(async_write_handler,
         _1, _2, 1, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
 
@@ -3275,8 +3289,8 @@ void test_4_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(1),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -3285,8 +3299,8 @@ void test_4_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3296,8 +3310,8 @@ void test_4_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -3307,8 +3321,8 @@ void test_4_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -3317,8 +3331,8 @@ void test_4_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3328,8 +3342,8 @@ void test_4_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
       bindns::bind(async_write_handler,
         _1, _2, 42, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
 
@@ -3339,8 +3353,8 @@ void test_4_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_at_least(42),
       bindns::bind(async_write_handler,
         _1, _2, 50, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
 
@@ -3349,8 +3363,8 @@ void test_4_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
       bindns::bind(async_write_handler,
         _1, _2, 1, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
 
@@ -3360,8 +3374,8 @@ void test_4_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
       bindns::bind(async_write_handler,
         _1, _2, 1, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
 
@@ -3371,8 +3385,8 @@ void test_4_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(1),
       bindns::bind(async_write_handler,
         _1, _2, 1, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
 
@@ -3381,8 +3395,8 @@ void test_4_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -3392,8 +3406,8 @@ void test_4_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -3403,8 +3417,8 @@ void test_4_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -3413,8 +3427,8 @@ void test_4_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
       bindns::bind(async_write_handler,
         _1, _2, 42, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
 
@@ -3424,8 +3438,8 @@ void test_4_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
       bindns::bind(async_write_handler,
         _1, _2, 42, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
 
@@ -3435,8 +3449,8 @@ void test_4_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers, boost::asio::transfer_exactly(42),
       bindns::bind(async_write_handler,
         _1, _2, 42, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
 
@@ -3445,8 +3459,8 @@ void test_4_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers, old_style_transfer_all,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3456,8 +3470,8 @@ void test_4_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers, old_style_transfer_all,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3467,8 +3481,8 @@ void test_4_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers, old_style_transfer_all,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3477,8 +3491,8 @@ void test_4_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers, short_transfer,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3488,8 +3502,8 @@ void test_4_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers, short_transfer,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3499,8 +3513,8 @@ void test_4_arg_vector_buffers_async_write()
   boost::asio::async_write(s, buffers, short_transfer,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3508,8 +3522,8 @@ void test_4_arg_vector_buffers_async_write()
   int i = boost::asio::async_write(s, buffers, short_transfer,
       archetypes::lazy_handler());
   BOOST_ASIO_CHECK(i == 42);
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 }
 
@@ -3523,10 +3537,10 @@ void test_4_arg_streambuf_async_write()
   using std::placeholders::_2;
 #endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
 
-  boost::asio::io_service ios;
-  test_stream s(ios);
+  boost::asio::io_context ioc;
+  test_stream s(ioc);
   boost::asio::streambuf sb;
-  boost::asio::const_buffers_1 buffers
+  boost::asio::const_buffer buffers
     = boost::asio::buffer(write_data, sizeof(write_data));
 
   s.reset();
@@ -3536,8 +3550,8 @@ void test_4_arg_streambuf_async_write()
   boost::asio::async_write(s, sb, boost::asio::transfer_all(),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3549,8 +3563,8 @@ void test_4_arg_streambuf_async_write()
   boost::asio::async_write(s, sb, boost::asio::transfer_all(),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3562,8 +3576,8 @@ void test_4_arg_streambuf_async_write()
   boost::asio::async_write(s, sb, boost::asio::transfer_all(),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3574,8 +3588,8 @@ void test_4_arg_streambuf_async_write()
   boost::asio::async_write(s, sb, boost::asio::transfer_at_least(1),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3587,8 +3601,8 @@ void test_4_arg_streambuf_async_write()
   boost::asio::async_write(s, sb, boost::asio::transfer_at_least(1),
       bindns::bind(async_write_handler,
         _1, _2, 1, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
 
@@ -3600,8 +3614,8 @@ void test_4_arg_streambuf_async_write()
   boost::asio::async_write(s, sb, boost::asio::transfer_at_least(1),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -3612,8 +3626,8 @@ void test_4_arg_streambuf_async_write()
   boost::asio::async_write(s, sb, boost::asio::transfer_at_least(10),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3625,8 +3639,8 @@ void test_4_arg_streambuf_async_write()
   boost::asio::async_write(s, sb, boost::asio::transfer_at_least(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -3638,8 +3652,8 @@ void test_4_arg_streambuf_async_write()
   boost::asio::async_write(s, sb, boost::asio::transfer_at_least(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -3650,8 +3664,8 @@ void test_4_arg_streambuf_async_write()
   boost::asio::async_write(s, sb, boost::asio::transfer_at_least(42),
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3663,8 +3677,8 @@ void test_4_arg_streambuf_async_write()
   boost::asio::async_write(s, sb, boost::asio::transfer_at_least(42),
       bindns::bind(async_write_handler,
         _1, _2, 42, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
 
@@ -3676,8 +3690,8 @@ void test_4_arg_streambuf_async_write()
   boost::asio::async_write(s, sb, boost::asio::transfer_at_least(42),
       bindns::bind(async_write_handler,
         _1, _2, 50, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 50));
 
@@ -3688,8 +3702,8 @@ void test_4_arg_streambuf_async_write()
   boost::asio::async_write(s, sb, boost::asio::transfer_exactly(1),
       bindns::bind(async_write_handler,
         _1, _2, 1, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
 
@@ -3701,8 +3715,8 @@ void test_4_arg_streambuf_async_write()
   boost::asio::async_write(s, sb, boost::asio::transfer_exactly(1),
       bindns::bind(async_write_handler,
         _1, _2, 1, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
 
@@ -3714,8 +3728,8 @@ void test_4_arg_streambuf_async_write()
   boost::asio::async_write(s, sb, boost::asio::transfer_exactly(1),
       bindns::bind(async_write_handler,
         _1, _2, 1, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 1));
 
@@ -3726,8 +3740,8 @@ void test_4_arg_streambuf_async_write()
   boost::asio::async_write(s, sb, boost::asio::transfer_exactly(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -3739,8 +3753,8 @@ void test_4_arg_streambuf_async_write()
   boost::asio::async_write(s, sb, boost::asio::transfer_exactly(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -3752,8 +3766,8 @@ void test_4_arg_streambuf_async_write()
   boost::asio::async_write(s, sb, boost::asio::transfer_exactly(10),
       bindns::bind(async_write_handler,
         _1, _2, 10, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 10));
 
@@ -3764,8 +3778,8 @@ void test_4_arg_streambuf_async_write()
   boost::asio::async_write(s, sb, boost::asio::transfer_exactly(42),
       bindns::bind(async_write_handler,
         _1, _2, 42, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
 
@@ -3777,8 +3791,8 @@ void test_4_arg_streambuf_async_write()
   boost::asio::async_write(s, sb, boost::asio::transfer_exactly(42),
       bindns::bind(async_write_handler,
         _1, _2, 42, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
 
@@ -3790,8 +3804,8 @@ void test_4_arg_streambuf_async_write()
   boost::asio::async_write(s, sb, boost::asio::transfer_exactly(42),
       bindns::bind(async_write_handler,
         _1, _2, 42, &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, 42));
 
@@ -3802,8 +3816,8 @@ void test_4_arg_streambuf_async_write()
   boost::asio::async_write(s, sb, old_style_transfer_all,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3815,8 +3829,8 @@ void test_4_arg_streambuf_async_write()
   boost::asio::async_write(s, sb, old_style_transfer_all,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3828,8 +3842,8 @@ void test_4_arg_streambuf_async_write()
   boost::asio::async_write(s, sb, old_style_transfer_all,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3840,8 +3854,8 @@ void test_4_arg_streambuf_async_write()
   boost::asio::async_write(s, sb, short_transfer,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3853,8 +3867,8 @@ void test_4_arg_streambuf_async_write()
   boost::asio::async_write(s, sb, short_transfer,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3866,8 +3880,8 @@ void test_4_arg_streambuf_async_write()
   boost::asio::async_write(s, sb, short_transfer,
       bindns::bind(async_write_handler,
         _1, _2, sizeof(write_data), &called));
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(called);
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 
@@ -3877,8 +3891,8 @@ void test_4_arg_streambuf_async_write()
   int i = boost::asio::async_write(s, sb, short_transfer,
       archetypes::lazy_handler());
   BOOST_ASIO_CHECK(i == 42);
-  ios.reset();
-  ios.run();
+  ioc.restart();
+  ioc.run();
   BOOST_ASIO_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 }
 
@@ -3886,27 +3900,27 @@ BOOST_ASIO_TEST_SUITE
 (
   "write",
   BOOST_ASIO_TEST_CASE(test_2_arg_zero_buffers_write)
-  BOOST_ASIO_TEST_CASE(test_2_arg_const_buffers_1_write)
-  BOOST_ASIO_TEST_CASE(test_2_arg_mutable_buffers_1_write)
+  BOOST_ASIO_TEST_CASE(test_2_arg_const_buffer_write)
+  BOOST_ASIO_TEST_CASE(test_2_arg_mutable_buffer_write)
   BOOST_ASIO_TEST_CASE(test_2_arg_vector_buffers_write)
   BOOST_ASIO_TEST_CASE(test_3_arg_nothrow_zero_buffers_write)
-  BOOST_ASIO_TEST_CASE(test_3_arg_nothrow_const_buffers_1_write)
-  BOOST_ASIO_TEST_CASE(test_3_arg_nothrow_mutable_buffers_1_write)
+  BOOST_ASIO_TEST_CASE(test_3_arg_nothrow_const_buffer_write)
+  BOOST_ASIO_TEST_CASE(test_3_arg_nothrow_mutable_buffer_write)
   BOOST_ASIO_TEST_CASE(test_3_arg_nothrow_vector_buffers_write)
-  BOOST_ASIO_TEST_CASE(test_3_arg_const_buffers_1_write)
-  BOOST_ASIO_TEST_CASE(test_3_arg_mutable_buffers_1_write)
+  BOOST_ASIO_TEST_CASE(test_3_arg_const_buffer_write)
+  BOOST_ASIO_TEST_CASE(test_3_arg_mutable_buffer_write)
   BOOST_ASIO_TEST_CASE(test_3_arg_vector_buffers_write)
-  BOOST_ASIO_TEST_CASE(test_4_arg_const_buffers_1_write)
-  BOOST_ASIO_TEST_CASE(test_4_arg_mutable_buffers_1_write)
+  BOOST_ASIO_TEST_CASE(test_4_arg_const_buffer_write)
+  BOOST_ASIO_TEST_CASE(test_4_arg_mutable_buffer_write)
   BOOST_ASIO_TEST_CASE(test_4_arg_vector_buffers_write)
-  BOOST_ASIO_TEST_CASE(test_3_arg_const_buffers_1_async_write)
-  BOOST_ASIO_TEST_CASE(test_3_arg_mutable_buffers_1_async_write)
+  BOOST_ASIO_TEST_CASE(test_3_arg_const_buffer_async_write)
+  BOOST_ASIO_TEST_CASE(test_3_arg_mutable_buffer_async_write)
   BOOST_ASIO_TEST_CASE(test_3_arg_boost_array_buffers_async_write)
   BOOST_ASIO_TEST_CASE(test_3_arg_std_array_buffers_async_write)
   BOOST_ASIO_TEST_CASE(test_3_arg_vector_buffers_async_write)
   BOOST_ASIO_TEST_CASE(test_3_arg_streambuf_async_write)
-  BOOST_ASIO_TEST_CASE(test_4_arg_const_buffers_1_async_write)
-  BOOST_ASIO_TEST_CASE(test_4_arg_mutable_buffers_1_async_write)
+  BOOST_ASIO_TEST_CASE(test_4_arg_const_buffer_async_write)
+  BOOST_ASIO_TEST_CASE(test_4_arg_mutable_buffer_async_write)
   BOOST_ASIO_TEST_CASE(test_4_arg_boost_array_buffers_async_write)
   BOOST_ASIO_TEST_CASE(test_4_arg_std_array_buffers_async_write)
   BOOST_ASIO_TEST_CASE(test_4_arg_vector_buffers_async_write)