diff options
Diffstat (limited to 'doc/html/boost_asio/example/cpp11/timeouts/blocking_token_tcp_client.cpp')
-rw-r--r-- | doc/html/boost_asio/example/cpp11/timeouts/blocking_token_tcp_client.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/doc/html/boost_asio/example/cpp11/timeouts/blocking_token_tcp_client.cpp b/doc/html/boost_asio/example/cpp11/timeouts/blocking_token_tcp_client.cpp index e13b0b1779..56c9fcfcfb 100644 --- a/doc/html/boost_asio/example/cpp11/timeouts/blocking_token_tcp_client.cpp +++ b/doc/html/boost_asio/example/cpp11/timeouts/blocking_token_tcp_client.cpp @@ -2,7 +2,7 @@ // blocking_token_tcp_client.cpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2019 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) @@ -22,13 +22,17 @@ using boost::asio::ip::tcp; +// We will use our sockets only with an io_context. +using tcp_socket = boost::asio::basic_stream_socket< + tcp, boost::asio::io_context::executor_type>; + //---------------------------------------------------------------------- // A custom completion token that makes asynchronous operations behave as // though they are blocking calls with a timeout. struct close_after { - close_after(std::chrono::steady_clock::duration t, tcp::socket& s) + close_after(std::chrono::steady_clock::duration t, tcp_socket& s) : timeout_(t), socket_(s) { } @@ -37,7 +41,7 @@ struct close_after std::chrono::steady_clock::duration timeout_; // The socket to be closed if the operation does not complete in time. - tcp::socket& socket_; + tcp_socket& socket_; }; namespace boost { @@ -125,7 +129,7 @@ public: private: std::chrono::steady_clock::duration timeout_; - tcp::socket& socket_; + tcp_socket& socket_; boost::system::error_code error_; T t_; }; @@ -150,7 +154,7 @@ int main(int argc, char* argv[]) // Resolve the host name and service to a list of endpoints. auto endpoints = tcp::resolver(io_context).resolve(argv[1], argv[2]); - tcp::socket socket(io_context); + tcp_socket socket(io_context); // Run an asynchronous connect operation with a timeout. boost::asio::async_connect(socket, endpoints, |