11 #ifndef ASIO_BASIC_SOCKET_IOSTREAM_HPP 12 #define ASIO_BASIC_SOCKET_IOSTREAM_HPP 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 20 #if !defined(ASIO_NO_IOSTREAM) 27 #if !defined(ASIO_HAS_VARIADIC_TEMPLATES) 44 # define ASIO_PRIVATE_CTR_DEF(n) \ 45 template <ASIO_VARIADIC_TPARAMS(n)> \ 46 explicit basic_socket_iostream(ASIO_VARIADIC_PARAMS(n)) \ 47 : std::basic_iostream<char>( \ 48 &this->detail::socket_iostream_base< \ 49 Protocol, StreamSocketService, Time, \ 50 TimeTraits, TimerService>::streambuf_) \ 52 this->setf(std::ios_base::unitbuf); \ 53 if (rdbuf()->connect(ASIO_VARIADIC_ARGS(n)) == 0) \ 54 this->setstate(std::ios_base::failbit); \ 67 # define ASIO_PRIVATE_CONNECT_DEF(n) \ 68 template <ASIO_VARIADIC_TPARAMS(n)> \ 69 void connect(ASIO_VARIADIC_PARAMS(n)) \ 71 if (rdbuf()->connect(ASIO_VARIADIC_ARGS(n)) == 0) \ 72 this->setstate(std::ios_base::failbit); \ 76 #endif // !defined(ASIO_HAS_VARIADIC_TEMPLATES) 85 template <
typename Protocol,
typename StreamSocketService,
86 typename Time,
typename TimeTraits,
typename TimerService>
97 template <
typename Protocol,
99 #if defined(ASIO_HAS_BOOST_DATE_TIME) \ 100 || defined(GENERATING_DOCUMENTATION) 101 typename Time = boost::posix_time::ptime,
102 typename TimeTraits = asio::time_traits<Time>,
105 typename Time = steady_timer::clock_type,
106 typename TimeTraits = steady_timer::traits_type,
107 typename TimerService = steady_timer::service_type>
111 StreamSocketService, Time, TimeTraits, TimerService>,
112 public std::basic_iostream<char>
117 #if defined(ASIO_HAS_BOOST_DATE_TIME) 127 #if defined(GENERATING_DOCUMENTATION) 128 typedef typename TimeTraits::time_type
time_type;
140 :
std::basic_iostream<char>(
141 &this->detail::socket_iostream_base<
142 Protocol, StreamSocketService, Time,
145 this->setf(std::ios_base::unitbuf);
148 #if defined(GENERATING_DOCUMENTATION) 155 template <
typename T1, ...,
typename TN>
157 #elif defined(ASIO_HAS_VARIADIC_TEMPLATES) 158 template <
typename... T>
159 explicit basic_socket_iostream(T... x)
160 : std::basic_iostream<char>(
162 Protocol, StreamSocketService, Time,
165 this->setf(std::ios_base::unitbuf);
166 if (rdbuf()->
connect(x...) == 0)
167 this->setstate(std::ios_base::failbit);
173 #if defined(GENERATING_DOCUMENTATION) 180 template <
typename T1, ...,
typename TN>
181 void connect(T1 t1, ..., TN tn);
182 #elif defined(ASIO_HAS_VARIADIC_TEMPLATES) 183 template <
typename... T>
186 if (rdbuf()->
connect(x...) == 0)
187 this->setstate(std::ios_base::failbit);
196 if (rdbuf()->
close() == 0)
197 this->setstate(std::ios_base::failbit);
202 Time, TimeTraits, TimerService>*
rdbuf()
const 205 Time, TimeTraits, TimerService
>*>(
207 Protocol, StreamSocketService, Time,
225 return rdbuf()->puberror();
234 return rdbuf()->expires_at();
248 rdbuf()->expires_at(expiry_time);
257 return rdbuf()->expires_from_now();
271 rdbuf()->expires_from_now(expiry_time);
279 #if !defined(ASIO_HAS_VARIADIC_TEMPLATES) 280 # undef ASIO_PRIVATE_CTR_DEF 281 # undef ASIO_PRIVATE_CONNECT_DEF 282 #endif // !defined(ASIO_HAS_VARIADIC_TEMPLATES) 284 #endif // !defined(ASIO_NO_IOSTREAM) 286 #endif // ASIO_BASIC_SOCKET_IOSTREAM_HPP Iostream interface for a socket.
duration_type expires_from_now() const
Get the timer's expiry time relative to now.
Default service implementation for a stream socket.
basic_socket_iostream()
Construct a basic_socket_iostream without establishing a connection.
Iterator connect(basic_socket< Protocol, SocketService > &s, Iterator begin)
Establishes a socket connection by trying each endpoint in a sequence.
const asio::error_code & error() const
Get the last error associated with the stream.
basic_socket_streambuf< Protocol, StreamSocketService, Time, TimeTraits, TimerService > streambuf_
clock_type::duration duration_type
clock_type::time_point time_type
Class to represent an error code value.
#define ASIO_VARIADIC_GENERATE(m)
void expires_at(const time_type &expiry_time)
Set the stream's expiry time as an absolute time.
traits_helper::duration_type duration_type
#define ASIO_PRIVATE_CONNECT_DEF(n)
time_type expires_at() const
Get the stream's expiry time as an absolute time.
ASIO_DECL int close(int d, state_type &state, asio::error_code &ec)
#define ASIO_PRIVATE_CTR_DEF(n)
Iostream streambuf for a socket.
traits_helper::time_type time_type
void expires_from_now(const duration_type &expiry_time)
Set the stream's expiry time relative to now.
Protocol::endpoint endpoint_type
The endpoint type.
void close()
Close the connection.
basic_socket_streambuf< Protocol, StreamSocketService, Time, TimeTraits, TimerService > * rdbuf() const
Return a pointer to the underlying streambuf.