// // basic_socket_streambuf.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2014 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 BOOST_ASIO_BASIC_SOCKET_STREAMBUF_HPP #define BOOST_ASIO_BASIC_SOCKET_STREAMBUF_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include #if !defined(BOOST_ASIO_NO_IOSTREAM) #include #include #include #include #include #include #include #if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME) # include #else # include #endif #if !defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) # include // 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; // typedef typename resolver_type::query resolver_query; // resolver_query query(x1, ..., xn); // resolve_and_connect(query); // return !ec_ ? this : 0; // } // This macro should only persist within this file. # define BOOST_ASIO_PRIVATE_CONNECT_DEF(n) \ template \ basic_socket_streambuf* connect(BOOST_ASIO_VARIADIC_PARAMS(n)) \ { \ init_buffers(); \ this->basic_socket::close(ec_); \ typedef typename Protocol::resolver resolver_type; \ typedef typename resolver_type::query resolver_query; \ resolver_query query(BOOST_ASIO_VARIADIC_ARGS(n)); \ resolve_and_connect(query); \ return !ec_ ? this : 0; \ } \ /**/ #endif // !defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) #include namespace boost { namespace asio { namespace detail { // A separate base class is used to ensure that the io_service is initialised // prior to the basic_socket_streambuf's basic_socket base class. class socket_streambuf_base { protected: io_service io_service_; }; } // namespace detail /// Iostream streambuf for a socket. template , #if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME) \ || defined(GENERATING_DOCUMENTATION) typename Time = boost::posix_time::ptime, typename TimeTraits = boost::asio::time_traits