]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/asio/example/cpp03/porthopper/client.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / asio / example / cpp03 / porthopper / client.cpp
index 276816fcf52e15d61e929db63785fe18d61d9e7a..05c020cd75f2f8687d67b65e9d7edb5649b77875 100644 (file)
@@ -2,7 +2,7 @@
 // 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)
@@ -37,20 +37,19 @@ int main(int argc, char* argv[])
     std::string host_name = argv[1];
     std::string port = argv[2];
 
-    boost::asio::io_service io_service;
+    boost::asio::io_context io_context;
 
     // Determine the location of the server.
-    tcp::resolver resolver(io_service);
-    tcp::resolver::query query(host_name, port);
-    tcp::endpoint remote_endpoint = *resolver.resolve(query);
+    tcp::resolver resolver(io_context);
+    tcp::endpoint remote_endpoint = *resolver.resolve(host_name, port).begin();
 
     // Establish the control connection to the server.
-    tcp::socket control_socket(io_service);
+    tcp::socket control_socket(io_context);
     control_socket.connect(remote_endpoint);
 
     // Create a datagram socket to receive data from the server.
     boost::shared_ptr<udp::socket> data_socket(
-        new udp::socket(io_service, udp::endpoint(udp::v4(), 0)));
+        new udp::socket(io_context, udp::endpoint(udp::v4(), 0)));
 
     // Determine what port we will receive data on.
     udp::endpoint data_endpoint = data_socket->local_endpoint();
@@ -82,7 +81,7 @@ int main(int argc, char* argv[])
 
       // Create the new data socket.
       boost::shared_ptr<udp::socket> new_data_socket(
-          new udp::socket(io_service, udp::endpoint(udp::v4(), 0)));
+          new udp::socket(io_context, udp::endpoint(udp::v4(), 0)));
 
       // Determine the new port we will use to receive data.
       udp::endpoint new_data_endpoint = new_data_socket->local_endpoint();
@@ -126,7 +125,7 @@ int main(int argc, char* argv[])
         // Even though we're performing a renegotation, we want to continue
         // receiving data as smoothly as possible. Therefore we will continue to
         // try to receive a frame from the server on the old data socket. If we
-        // receive a frame on this socket we will interrupt the io_service,
+        // receive a frame on this socket we will interrupt the io_context,
         // print the frame, and resume waiting for the other operations to
         // complete.
         frame f2;
@@ -138,19 +137,19 @@ int main(int argc, char* argv[])
                 lambda::if_(!lambda::_1)
                 [
                   // We have successfully received a frame on the old data
-                  // socket. Stop the io_service so that we can print it.
-                  lambda::bind(&boost::asio::io_service::stop, &io_service),
+                  // socket. Stop the io_context so that we can print it.
+                  lambda::bind(&boost::asio::io_context::stop, &io_context),
                   lambda::var(done) = false
                 ]
               ));
         }
 
         // Run the operations in parallel. This will block until all operations
-        // have finished, or until the io_service is interrupted. (No threads!)
-        io_service.reset();
-        io_service.run();
+        // have finished, or until the io_context is interrupted. (No threads!)
+        io_context.restart();
+        io_context.run();
 
-        // If the io_service.run() was interrupted then we have received a frame
+        // If the io_context.run() was interrupted then we have received a frame
         // on the old data socket. We need to keep waiting for the renegotation
         // operations to complete.
         if (!done)