// server.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)
class udp_server
{
public:
- udp_server(boost::asio::io_service& io_service)
- : socket_(io_service, udp::endpoint(udp::v4(), 13))
+ udp_server(boost::asio::io_context& io_context)
+ : socket_(io_context, udp::endpoint(udp::v4(), 13))
{
start_receive();
}
void handle_receive(const boost::system::error_code& error,
std::size_t /*bytes_transferred*/)
{
- if (!error || error == boost::asio::error::message_size)
+ if (!error)
{
boost::shared_ptr<std::string> message(
new std::string(make_daytime_string()));
{
try
{
- boost::asio::io_service io_service;
- udp_server server(io_service);
- io_service.run();
+ boost::asio::io_context io_context;
+ udp_server server(io_context);
+ io_context.run();
}
catch (std::exception& e)
{