// blocking_udp_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)
//
#include <boost/asio/deadline_timer.hpp>
-#include <boost/asio/io_service.hpp>
+#include <boost/asio/io_context.hpp>
#include <boost/asio/ip/udp.hpp>
#include <cstdlib>
#include <boost/bind.hpp>
// | |
// +----------------+
//
-// The client object runs the io_service to block thread execution until the
+// The client object runs the io_context to block thread execution until the
// actor completes.
//
class client
{
public:
client(const udp::endpoint& listen_endpoint)
- : socket_(io_service_, listen_endpoint),
- deadline_(io_service_)
+ : socket_(io_context_, listen_endpoint),
+ 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
boost::bind(&client::handle_receive, _1, _2, &ec, &length));
// 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);
return length;
}
}
private:
- boost::asio::io_service io_service_;
+ boost::asio::io_context io_context_;
udp::socket socket_;
deadline_timer deadline_;
};
}
udp::endpoint listen_endpoint(
- boost::asio::ip::address::from_string(argv[1]),
+ boost::asio::ip::make_address(argv[1]),
std::atoi(argv[2]));
client c(listen_endpoint);