]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/asio/example/cpp03/timeouts/blocking_tcp_client.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / asio / example / cpp03 / timeouts / blocking_tcp_client.cpp
index d518834c288218dc460f633ebef9d6e59e91e7e8..67224cfd0f09439dda7173312cf0d448df53d524 100644 (file)
@@ -2,7 +2,7 @@
 // blocking_tcp_client.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)
@@ -10,7 +10,7 @@
 
 #include <boost/asio/connect.hpp>
 #include <boost/asio/deadline_timer.hpp>
-#include <boost/asio/io_service.hpp>
+#include <boost/asio/io_context.hpp>
 #include <boost/asio/ip/tcp.hpp>
 #include <boost/asio/read_until.hpp>
 #include <boost/asio/streambuf.hpp>
@@ -48,14 +48,14 @@ using boost::lambda::_1;
 // and any outstanding operations are consequently cancelled. The socket
 // operations themselves use boost::lambda function objects as completion
 // handlers. For a given socket operation, the client object runs the
-// io_service to block thread execution until the actor completes.
+// io_context to block thread execution until the actor completes.
 //
 class client
 {
 public:
   client()
-    : socket_(io_service_),
-      deadline_(io_service_)
+    : socket_(io_context_),
+      deadline_(io_context_)
   {
     // No deadline is required until the first socket operation is started. We
     // set the deadline to positive infinity so that the actor takes no action
@@ -70,8 +70,8 @@ public:
       boost::posix_time::time_duration timeout)
   {
     // Resolve the host name and service to a list of endpoints.
-    tcp::resolver::query query(host, service);
-    tcp::resolver::iterator iter = tcp::resolver(io_service_).resolve(query);
+    tcp::resolver::results_type endpoints =
+      tcp::resolver(io_context_).resolve(host, service);
 
     // Set a deadline for the asynchronous operation. As a host name may
     // resolve to multiple endpoints, this function uses the composed operation
@@ -90,10 +90,10 @@ public:
     // object is used as a callback and will update the ec variable when the
     // operation completes. The blocking_udp_client.cpp example shows how you
     // can use boost::bind rather than boost::lambda.
-    boost::asio::async_connect(socket_, iter, var(ec) = _1);
+    boost::asio::async_connect(socket_, endpoints, var(ec) = _1);
 
     // Block until the asynchronous operation has completed.
-    do io_service_.run_one(); while (ec == boost::asio::error::would_block);
+    do io_context_.run_one(); while (ec == boost::asio::error::would_block);
 
     // Determine whether a connection was successfully established. The
     // deadline actor may have had a chance to run and close our socket, even
@@ -126,7 +126,7 @@ public:
     boost::asio::async_read_until(socket_, input_buffer_, '\n', var(ec) = _1);
 
     // Block until the asynchronous operation has completed.
-    do io_service_.run_one(); while (ec == boost::asio::error::would_block);
+    do io_context_.run_one(); while (ec == boost::asio::error::would_block);
 
     if (ec)
       throw boost::system::system_error(ec);
@@ -161,7 +161,7 @@ public:
     boost::asio::async_write(socket_, boost::asio::buffer(data), var(ec) = _1);
 
     // Block until the asynchronous operation has completed.
-    do io_service_.run_one(); while (ec == boost::asio::error::would_block);
+    do io_context_.run_one(); while (ec == boost::asio::error::would_block);
 
     if (ec)
       throw boost::system::system_error(ec);
@@ -190,7 +190,7 @@ private:
     deadline_.async_wait(bind(&client::check_deadline, this));
   }
 
-  boost::asio::io_service io_service_;
+  boost::asio::io_context io_context_;
   tcp::socket socket_;
   deadline_timer deadline_;
   boost::asio::streambuf input_buffer_;