// 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)
public:
/// Constructor opens the acceptor and starts waiting for the first incoming
/// connection.
- server(boost::asio::io_service& io_service, unsigned short port)
- : acceptor_(io_service,
+ server(boost::asio::io_context& io_context, unsigned short port)
+ : acceptor_(io_context,
boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port))
{
// Create the data to be sent to each client.
stocks_.push_back(s);
// Start an accept operation for a new connection.
- connection_ptr new_conn(new connection(acceptor_.get_io_service()));
+ connection_ptr new_conn(new connection(acceptor_.get_io_context()));
acceptor_.async_accept(new_conn->socket(),
boost::bind(&server::handle_accept, this,
boost::asio::placeholders::error, new_conn));
}
// Start an accept operation for a new connection.
- connection_ptr new_conn(new connection(acceptor_.get_io_service()));
+ connection_ptr new_conn(new connection(acceptor_.get_io_context()));
acceptor_.async_accept(new_conn->socket(),
boost::bind(&server::handle_accept, this,
boost::asio::placeholders::error, new_conn));
}
unsigned short port = boost::lexical_cast<unsigned short>(argv[1]);
- boost::asio::io_service io_service;
- s11n_example::server server(io_service, port);
- io_service.run();
+ boost::asio::io_context io_context;
+ s11n_example::server server(io_context, port);
+ io_context.run();
}
catch (std::exception& e)
{