// // basic_socket_streambuf.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2015 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) // #ifndef ASIO_BASIC_SOCKET_STREAMBUF_HPP #define ASIO_BASIC_SOCKET_STREAMBUF_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include "asio/detail/config.hpp" #if !defined(ASIO_NO_IOSTREAM) #include #include "asio/basic_socket.hpp" #include "asio/deadline_timer_service.hpp" #include "asio/detail/array.hpp" #include "asio/detail/throw_error.hpp" #include "asio/io_context.hpp" #include "asio/stream_socket_service.hpp" #if defined(ASIO_HAS_BOOST_DATE_TIME) # include "asio/deadline_timer.hpp" #else # include "asio/steady_timer.hpp" #endif #if !defined(ASIO_HAS_VARIADIC_TEMPLATES) # include "asio/detail/variadic_templates.hpp" // A macro that should expand to: // template // basic_socket_streambuf* connect( // T1 x1, ..., Tn xn) // { // init_buffers(); // this->basic_socket::close(ec_); // typedef typename Protocol::resolver resolver_type; // resolver_type resolver(detail::socket_streambuf_base::io_context_); // connect_to_endpoints( // resolver.resolve(x1, ..., xn, ec_)); // return !ec_ ? this : 0; // } // This macro should only persist within this file. # define ASIO_PRIVATE_CONNECT_DEF(n) \ template \ basic_socket_streambuf* connect( \ ASIO_VARIADIC_BYVAL_PARAMS(n)) \ { \ init_buffers(); \ this->basic_socket::close(ec_); \ typedef typename Protocol::resolver resolver_type; \ resolver_type resolver(detail::socket_streambuf_base::io_context_); \ connect_to_endpoints( \ resolver.resolve(ASIO_VARIADIC_BYVAL_ARGS(n), ec_)); \ return !ec_ ? this : 0; \ } \ /**/ #endif // !defined(ASIO_HAS_VARIADIC_TEMPLATES) #include "asio/detail/push_options.hpp" namespace asio { namespace detail { // A separate base class is used to ensure that the io_context is initialised // prior to the basic_socket_streambuf's basic_socket base class. class socket_streambuf_base { protected: io_context io_context_; }; } // namespace detail /// Iostream streambuf for a socket. template , #if defined(ASIO_HAS_BOOST_DATE_TIME) \ || defined(GENERATING_DOCUMENTATION) typename Time = boost::posix_time::ptime, typename TimeTraits = asio::time_traits