//
// 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)
//
// 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/ip/tcp.hpp>
#include <boost/asio/read_until.hpp>
#include <boost/asio/streambuf.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/read_until.hpp>
#include <boost/asio/streambuf.hpp>
// 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
// 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
{
// 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
{
// 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::posix_time::time_duration timeout)
{
// Resolve the host name and service to a list of endpoints.
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
// Set a deadline for the asynchronous operation. As a host name may
// resolve to multiple endpoints, this function uses the composed operation
// 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.
// 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.
// Determine whether a connection was successfully established. The
// deadline actor may have had a chance to run and close our socket, even
// Determine whether a connection was successfully established. The
// deadline actor may have had a chance to run and close our socket, even
boost::asio::async_read_until(socket_, input_buffer_, '\n', var(ec) = _1);
// Block until the asynchronous operation has completed.
boost::asio::async_read_until(socket_, input_buffer_, '\n', var(ec) = _1);
// Block until the asynchronous operation has completed.
boost::asio::async_write(socket_, boost::asio::buffer(data), var(ec) = _1);
// Block until the asynchronous operation has completed.
boost::asio::async_write(socket_, boost::asio::buffer(data), var(ec) = _1);
// Block until the asynchronous operation has completed.