Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1218 lines
49KB

  1. //
  2. // write.hpp
  3. // ~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef ASIO_WRITE_HPP
  11. #define ASIO_WRITE_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include "asio/detail/config.hpp"
  16. #include <cstddef>
  17. #include "asio/async_result.hpp"
  18. #include "asio/buffer.hpp"
  19. #include "asio/error.hpp"
  20. #if !defined(ASIO_NO_EXTENSIONS)
  21. # include "asio/basic_streambuf_fwd.hpp"
  22. #endif // !defined(ASIO_NO_EXTENSIONS)
  23. #include "asio/detail/push_options.hpp"
  24. namespace asio {
  25. /**
  26. * @defgroup write asio::write
  27. *
  28. * @brief The @c write function is a composed operation that writes a certain
  29. * amount of data to a stream before returning.
  30. */
  31. /*@{*/
  32. /// Write all of the supplied data to a stream before returning.
  33. /**
  34. * This function is used to write a certain number of bytes of data to a stream.
  35. * The call will block until one of the following conditions is true:
  36. *
  37. * @li All of the data in the supplied buffers has been written. That is, the
  38. * bytes transferred is equal to the sum of the buffer sizes.
  39. *
  40. * @li An error occurred.
  41. *
  42. * This operation is implemented in terms of zero or more calls to the stream's
  43. * write_some function.
  44. *
  45. * @param s The stream to which the data is to be written. The type must support
  46. * the SyncWriteStream concept.
  47. *
  48. * @param buffers One or more buffers containing the data to be written. The sum
  49. * of the buffer sizes indicates the maximum number of bytes to write to the
  50. * stream.
  51. *
  52. * @returns The number of bytes transferred.
  53. *
  54. * @throws asio::system_error Thrown on failure.
  55. *
  56. * @par Example
  57. * To write a single data buffer use the @ref buffer function as follows:
  58. * @code asio::write(s, asio::buffer(data, size)); @endcode
  59. * See the @ref buffer documentation for information on writing multiple
  60. * buffers in one go, and how to use it with arrays, boost::array or
  61. * std::vector.
  62. *
  63. * @note This overload is equivalent to calling:
  64. * @code asio::write(
  65. * s, buffers,
  66. * asio::transfer_all()); @endcode
  67. */
  68. template <typename SyncWriteStream, typename ConstBufferSequence>
  69. std::size_t write(SyncWriteStream& s, const ConstBufferSequence& buffers,
  70. typename enable_if<
  71. is_const_buffer_sequence<ConstBufferSequence>::value
  72. >::type* = 0);
  73. /// Write all of the supplied data to a stream before returning.
  74. /**
  75. * This function is used to write a certain number of bytes of data to a stream.
  76. * The call will block until one of the following conditions is true:
  77. *
  78. * @li All of the data in the supplied buffers has been written. That is, the
  79. * bytes transferred is equal to the sum of the buffer sizes.
  80. *
  81. * @li An error occurred.
  82. *
  83. * This operation is implemented in terms of zero or more calls to the stream's
  84. * write_some function.
  85. *
  86. * @param s The stream to which the data is to be written. The type must support
  87. * the SyncWriteStream concept.
  88. *
  89. * @param buffers One or more buffers containing the data to be written. The sum
  90. * of the buffer sizes indicates the maximum number of bytes to write to the
  91. * stream.
  92. *
  93. * @param ec Set to indicate what error occurred, if any.
  94. *
  95. * @returns The number of bytes transferred.
  96. *
  97. * @par Example
  98. * To write a single data buffer use the @ref buffer function as follows:
  99. * @code asio::write(s, asio::buffer(data, size), ec); @endcode
  100. * See the @ref buffer documentation for information on writing multiple
  101. * buffers in one go, and how to use it with arrays, boost::array or
  102. * std::vector.
  103. *
  104. * @note This overload is equivalent to calling:
  105. * @code asio::write(
  106. * s, buffers,
  107. * asio::transfer_all(), ec); @endcode
  108. */
  109. template <typename SyncWriteStream, typename ConstBufferSequence>
  110. std::size_t write(SyncWriteStream& s, const ConstBufferSequence& buffers,
  111. asio::error_code& ec,
  112. typename enable_if<
  113. is_const_buffer_sequence<ConstBufferSequence>::value
  114. >::type* = 0);
  115. /// Write a certain amount of data to a stream before returning.
  116. /**
  117. * This function is used to write a certain number of bytes of data to a stream.
  118. * The call will block until one of the following conditions is true:
  119. *
  120. * @li All of the data in the supplied buffers has been written. That is, the
  121. * bytes transferred is equal to the sum of the buffer sizes.
  122. *
  123. * @li The completion_condition function object returns 0.
  124. *
  125. * This operation is implemented in terms of zero or more calls to the stream's
  126. * write_some function.
  127. *
  128. * @param s The stream to which the data is to be written. The type must support
  129. * the SyncWriteStream concept.
  130. *
  131. * @param buffers One or more buffers containing the data to be written. The sum
  132. * of the buffer sizes indicates the maximum number of bytes to write to the
  133. * stream.
  134. *
  135. * @param completion_condition The function object to be called to determine
  136. * whether the write operation is complete. The signature of the function object
  137. * must be:
  138. * @code std::size_t completion_condition(
  139. * // Result of latest write_some operation.
  140. * const asio::error_code& error,
  141. *
  142. * // Number of bytes transferred so far.
  143. * std::size_t bytes_transferred
  144. * ); @endcode
  145. * A return value of 0 indicates that the write operation is complete. A
  146. * non-zero return value indicates the maximum number of bytes to be written on
  147. * the next call to the stream's write_some function.
  148. *
  149. * @returns The number of bytes transferred.
  150. *
  151. * @throws asio::system_error Thrown on failure.
  152. *
  153. * @par Example
  154. * To write a single data buffer use the @ref buffer function as follows:
  155. * @code asio::write(s, asio::buffer(data, size),
  156. * asio::transfer_at_least(32)); @endcode
  157. * See the @ref buffer documentation for information on writing multiple
  158. * buffers in one go, and how to use it with arrays, boost::array or
  159. * std::vector.
  160. */
  161. template <typename SyncWriteStream, typename ConstBufferSequence,
  162. typename CompletionCondition>
  163. std::size_t write(SyncWriteStream& s, const ConstBufferSequence& buffers,
  164. CompletionCondition completion_condition,
  165. typename enable_if<
  166. is_const_buffer_sequence<ConstBufferSequence>::value
  167. >::type* = 0);
  168. /// Write a certain amount of data to a stream before returning.
  169. /**
  170. * This function is used to write a certain number of bytes of data to a stream.
  171. * The call will block until one of the following conditions is true:
  172. *
  173. * @li All of the data in the supplied buffers has been written. That is, the
  174. * bytes transferred is equal to the sum of the buffer sizes.
  175. *
  176. * @li The completion_condition function object returns 0.
  177. *
  178. * This operation is implemented in terms of zero or more calls to the stream's
  179. * write_some function.
  180. *
  181. * @param s The stream to which the data is to be written. The type must support
  182. * the SyncWriteStream concept.
  183. *
  184. * @param buffers One or more buffers containing the data to be written. The sum
  185. * of the buffer sizes indicates the maximum number of bytes to write to the
  186. * stream.
  187. *
  188. * @param completion_condition The function object to be called to determine
  189. * whether the write operation is complete. The signature of the function object
  190. * must be:
  191. * @code std::size_t completion_condition(
  192. * // Result of latest write_some operation.
  193. * const asio::error_code& error,
  194. *
  195. * // Number of bytes transferred so far.
  196. * std::size_t bytes_transferred
  197. * ); @endcode
  198. * A return value of 0 indicates that the write operation is complete. A
  199. * non-zero return value indicates the maximum number of bytes to be written on
  200. * the next call to the stream's write_some function.
  201. *
  202. * @param ec Set to indicate what error occurred, if any.
  203. *
  204. * @returns The number of bytes written. If an error occurs, returns the total
  205. * number of bytes successfully transferred prior to the error.
  206. */
  207. template <typename SyncWriteStream, typename ConstBufferSequence,
  208. typename CompletionCondition>
  209. std::size_t write(SyncWriteStream& s, const ConstBufferSequence& buffers,
  210. CompletionCondition completion_condition, asio::error_code& ec,
  211. typename enable_if<
  212. is_const_buffer_sequence<ConstBufferSequence>::value
  213. >::type* = 0);
  214. #if !defined(ASIO_NO_DYNAMIC_BUFFER_V1)
  215. /// Write all of the supplied data to a stream before returning.
  216. /**
  217. * This function is used to write a certain number of bytes of data to a stream.
  218. * The call will block until one of the following conditions is true:
  219. *
  220. * @li All of the data in the supplied dynamic buffer sequence has been written.
  221. *
  222. * @li An error occurred.
  223. *
  224. * This operation is implemented in terms of zero or more calls to the stream's
  225. * write_some function.
  226. *
  227. * @param s The stream to which the data is to be written. The type must support
  228. * the SyncWriteStream concept.
  229. *
  230. * @param buffers The dynamic buffer sequence from which data will be written.
  231. * Successfully written data is automatically consumed from the buffers.
  232. *
  233. * @returns The number of bytes transferred.
  234. *
  235. * @throws asio::system_error Thrown on failure.
  236. *
  237. * @note This overload is equivalent to calling:
  238. * @code asio::write(
  239. * s, buffers,
  240. * asio::transfer_all()); @endcode
  241. */
  242. template <typename SyncWriteStream, typename DynamicBuffer_v1>
  243. std::size_t write(SyncWriteStream& s,
  244. ASIO_MOVE_ARG(DynamicBuffer_v1) buffers,
  245. typename enable_if<
  246. is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
  247. && !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
  248. >::type* = 0);
  249. /// Write all of the supplied data to a stream before returning.
  250. /**
  251. * This function is used to write a certain number of bytes of data to a stream.
  252. * The call will block until one of the following conditions is true:
  253. *
  254. * @li All of the data in the supplied dynamic buffer sequence has been written.
  255. *
  256. * @li An error occurred.
  257. *
  258. * This operation is implemented in terms of zero or more calls to the stream's
  259. * write_some function.
  260. *
  261. * @param s The stream to which the data is to be written. The type must support
  262. * the SyncWriteStream concept.
  263. *
  264. * @param buffers The dynamic buffer sequence from which data will be written.
  265. * Successfully written data is automatically consumed from the buffers.
  266. *
  267. * @param ec Set to indicate what error occurred, if any.
  268. *
  269. * @returns The number of bytes transferred.
  270. *
  271. * @note This overload is equivalent to calling:
  272. * @code asio::write(
  273. * s, buffers,
  274. * asio::transfer_all(), ec); @endcode
  275. */
  276. template <typename SyncWriteStream, typename DynamicBuffer_v1>
  277. std::size_t write(SyncWriteStream& s,
  278. ASIO_MOVE_ARG(DynamicBuffer_v1) buffers,
  279. asio::error_code& ec,
  280. typename enable_if<
  281. is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
  282. && !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
  283. >::type* = 0);
  284. /// Write a certain amount of data to a stream before returning.
  285. /**
  286. * This function is used to write a certain number of bytes of data to a stream.
  287. * The call will block until one of the following conditions is true:
  288. *
  289. * @li All of the data in the supplied dynamic buffer sequence has been written.
  290. *
  291. * @li The completion_condition function object returns 0.
  292. *
  293. * This operation is implemented in terms of zero or more calls to the stream's
  294. * write_some function.
  295. *
  296. * @param s The stream to which the data is to be written. The type must support
  297. * the SyncWriteStream concept.
  298. *
  299. * @param buffers The dynamic buffer sequence from which data will be written.
  300. * Successfully written data is automatically consumed from the buffers.
  301. *
  302. * @param completion_condition The function object to be called to determine
  303. * whether the write operation is complete. The signature of the function object
  304. * must be:
  305. * @code std::size_t completion_condition(
  306. * // Result of latest write_some operation.
  307. * const asio::error_code& error,
  308. *
  309. * // Number of bytes transferred so far.
  310. * std::size_t bytes_transferred
  311. * ); @endcode
  312. * A return value of 0 indicates that the write operation is complete. A
  313. * non-zero return value indicates the maximum number of bytes to be written on
  314. * the next call to the stream's write_some function.
  315. *
  316. * @returns The number of bytes transferred.
  317. *
  318. * @throws asio::system_error Thrown on failure.
  319. */
  320. template <typename SyncWriteStream, typename DynamicBuffer_v1,
  321. typename CompletionCondition>
  322. std::size_t write(SyncWriteStream& s,
  323. ASIO_MOVE_ARG(DynamicBuffer_v1) buffers,
  324. CompletionCondition completion_condition,
  325. typename enable_if<
  326. is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
  327. && !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
  328. >::type* = 0);
  329. /// Write a certain amount of data to a stream before returning.
  330. /**
  331. * This function is used to write a certain number of bytes of data to a stream.
  332. * The call will block until one of the following conditions is true:
  333. *
  334. * @li All of the data in the supplied dynamic buffer sequence has been written.
  335. *
  336. * @li The completion_condition function object returns 0.
  337. *
  338. * This operation is implemented in terms of zero or more calls to the stream's
  339. * write_some function.
  340. *
  341. * @param s The stream to which the data is to be written. The type must support
  342. * the SyncWriteStream concept.
  343. *
  344. * @param buffers The dynamic buffer sequence from which data will be written.
  345. * Successfully written data is automatically consumed from the buffers.
  346. *
  347. * @param completion_condition The function object to be called to determine
  348. * whether the write operation is complete. The signature of the function object
  349. * must be:
  350. * @code std::size_t completion_condition(
  351. * // Result of latest write_some operation.
  352. * const asio::error_code& error,
  353. *
  354. * // Number of bytes transferred so far.
  355. * std::size_t bytes_transferred
  356. * ); @endcode
  357. * A return value of 0 indicates that the write operation is complete. A
  358. * non-zero return value indicates the maximum number of bytes to be written on
  359. * the next call to the stream's write_some function.
  360. *
  361. * @param ec Set to indicate what error occurred, if any.
  362. *
  363. * @returns The number of bytes written. If an error occurs, returns the total
  364. * number of bytes successfully transferred prior to the error.
  365. */
  366. template <typename SyncWriteStream, typename DynamicBuffer_v1,
  367. typename CompletionCondition>
  368. std::size_t write(SyncWriteStream& s,
  369. ASIO_MOVE_ARG(DynamicBuffer_v1) buffers,
  370. CompletionCondition completion_condition, asio::error_code& ec,
  371. typename enable_if<
  372. is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
  373. && !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
  374. >::type* = 0);
  375. #if !defined(ASIO_NO_EXTENSIONS)
  376. #if !defined(ASIO_NO_IOSTREAM)
  377. /// Write all of the supplied data to a stream before returning.
  378. /**
  379. * This function is used to write a certain number of bytes of data to a stream.
  380. * The call will block until one of the following conditions is true:
  381. *
  382. * @li All of the data in the supplied basic_streambuf has been written.
  383. *
  384. * @li An error occurred.
  385. *
  386. * This operation is implemented in terms of zero or more calls to the stream's
  387. * write_some function.
  388. *
  389. * @param s The stream to which the data is to be written. The type must support
  390. * the SyncWriteStream concept.
  391. *
  392. * @param b The basic_streambuf object from which data will be written.
  393. *
  394. * @returns The number of bytes transferred.
  395. *
  396. * @throws asio::system_error Thrown on failure.
  397. *
  398. * @note This overload is equivalent to calling:
  399. * @code asio::write(
  400. * s, b,
  401. * asio::transfer_all()); @endcode
  402. */
  403. template <typename SyncWriteStream, typename Allocator>
  404. std::size_t write(SyncWriteStream& s, basic_streambuf<Allocator>& b);
  405. /// Write all of the supplied data to a stream before returning.
  406. /**
  407. * This function is used to write a certain number of bytes of data to a stream.
  408. * The call will block until one of the following conditions is true:
  409. *
  410. * @li All of the data in the supplied basic_streambuf has been written.
  411. *
  412. * @li An error occurred.
  413. *
  414. * This operation is implemented in terms of zero or more calls to the stream's
  415. * write_some function.
  416. *
  417. * @param s The stream to which the data is to be written. The type must support
  418. * the SyncWriteStream concept.
  419. *
  420. * @param b The basic_streambuf object from which data will be written.
  421. *
  422. * @param ec Set to indicate what error occurred, if any.
  423. *
  424. * @returns The number of bytes transferred.
  425. *
  426. * @note This overload is equivalent to calling:
  427. * @code asio::write(
  428. * s, b,
  429. * asio::transfer_all(), ec); @endcode
  430. */
  431. template <typename SyncWriteStream, typename Allocator>
  432. std::size_t write(SyncWriteStream& s, basic_streambuf<Allocator>& b,
  433. asio::error_code& ec);
  434. /// Write a certain amount of data to a stream before returning.
  435. /**
  436. * This function is used to write a certain number of bytes of data to a stream.
  437. * The call will block until one of the following conditions is true:
  438. *
  439. * @li All of the data in the supplied basic_streambuf has been written.
  440. *
  441. * @li The completion_condition function object returns 0.
  442. *
  443. * This operation is implemented in terms of zero or more calls to the stream's
  444. * write_some function.
  445. *
  446. * @param s The stream to which the data is to be written. The type must support
  447. * the SyncWriteStream concept.
  448. *
  449. * @param b The basic_streambuf object from which data will be written.
  450. *
  451. * @param completion_condition The function object to be called to determine
  452. * whether the write operation is complete. The signature of the function object
  453. * must be:
  454. * @code std::size_t completion_condition(
  455. * // Result of latest write_some operation.
  456. * const asio::error_code& error,
  457. *
  458. * // Number of bytes transferred so far.
  459. * std::size_t bytes_transferred
  460. * ); @endcode
  461. * A return value of 0 indicates that the write operation is complete. A
  462. * non-zero return value indicates the maximum number of bytes to be written on
  463. * the next call to the stream's write_some function.
  464. *
  465. * @returns The number of bytes transferred.
  466. *
  467. * @throws asio::system_error Thrown on failure.
  468. */
  469. template <typename SyncWriteStream, typename Allocator,
  470. typename CompletionCondition>
  471. std::size_t write(SyncWriteStream& s, basic_streambuf<Allocator>& b,
  472. CompletionCondition completion_condition);
  473. /// Write a certain amount of data to a stream before returning.
  474. /**
  475. * This function is used to write a certain number of bytes of data to a stream.
  476. * The call will block until one of the following conditions is true:
  477. *
  478. * @li All of the data in the supplied basic_streambuf has been written.
  479. *
  480. * @li The completion_condition function object returns 0.
  481. *
  482. * This operation is implemented in terms of zero or more calls to the stream's
  483. * write_some function.
  484. *
  485. * @param s The stream to which the data is to be written. The type must support
  486. * the SyncWriteStream concept.
  487. *
  488. * @param b The basic_streambuf object from which data will be written.
  489. *
  490. * @param completion_condition The function object to be called to determine
  491. * whether the write operation is complete. The signature of the function object
  492. * must be:
  493. * @code std::size_t completion_condition(
  494. * // Result of latest write_some operation.
  495. * const asio::error_code& error,
  496. *
  497. * // Number of bytes transferred so far.
  498. * std::size_t bytes_transferred
  499. * ); @endcode
  500. * A return value of 0 indicates that the write operation is complete. A
  501. * non-zero return value indicates the maximum number of bytes to be written on
  502. * the next call to the stream's write_some function.
  503. *
  504. * @param ec Set to indicate what error occurred, if any.
  505. *
  506. * @returns The number of bytes written. If an error occurs, returns the total
  507. * number of bytes successfully transferred prior to the error.
  508. */
  509. template <typename SyncWriteStream, typename Allocator,
  510. typename CompletionCondition>
  511. std::size_t write(SyncWriteStream& s, basic_streambuf<Allocator>& b,
  512. CompletionCondition completion_condition, asio::error_code& ec);
  513. #endif // !defined(ASIO_NO_IOSTREAM)
  514. #endif // !defined(ASIO_NO_EXTENSIONS)
  515. #endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1)
  516. /// Write all of the supplied data to a stream before returning.
  517. /**
  518. * This function is used to write a certain number of bytes of data to a stream.
  519. * The call will block until one of the following conditions is true:
  520. *
  521. * @li All of the data in the supplied dynamic buffer sequence has been written.
  522. *
  523. * @li An error occurred.
  524. *
  525. * This operation is implemented in terms of zero or more calls to the stream's
  526. * write_some function.
  527. *
  528. * @param s The stream to which the data is to be written. The type must support
  529. * the SyncWriteStream concept.
  530. *
  531. * @param buffers The dynamic buffer sequence from which data will be written.
  532. * Successfully written data is automatically consumed from the buffers.
  533. *
  534. * @returns The number of bytes transferred.
  535. *
  536. * @throws asio::system_error Thrown on failure.
  537. *
  538. * @note This overload is equivalent to calling:
  539. * @code asio::write(
  540. * s, buffers,
  541. * asio::transfer_all()); @endcode
  542. */
  543. template <typename SyncWriteStream, typename DynamicBuffer_v2>
  544. std::size_t write(SyncWriteStream& s, DynamicBuffer_v2 buffers,
  545. typename enable_if<
  546. is_dynamic_buffer_v2<DynamicBuffer_v2>::value
  547. >::type* = 0);
  548. /// Write all of the supplied data to a stream before returning.
  549. /**
  550. * This function is used to write a certain number of bytes of data to a stream.
  551. * The call will block until one of the following conditions is true:
  552. *
  553. * @li All of the data in the supplied dynamic buffer sequence has been written.
  554. *
  555. * @li An error occurred.
  556. *
  557. * This operation is implemented in terms of zero or more calls to the stream's
  558. * write_some function.
  559. *
  560. * @param s The stream to which the data is to be written. The type must support
  561. * the SyncWriteStream concept.
  562. *
  563. * @param buffers The dynamic buffer sequence from which data will be written.
  564. * Successfully written data is automatically consumed from the buffers.
  565. *
  566. * @param ec Set to indicate what error occurred, if any.
  567. *
  568. * @returns The number of bytes transferred.
  569. *
  570. * @note This overload is equivalent to calling:
  571. * @code asio::write(
  572. * s, buffers,
  573. * asio::transfer_all(), ec); @endcode
  574. */
  575. template <typename SyncWriteStream, typename DynamicBuffer_v2>
  576. std::size_t write(SyncWriteStream& s, DynamicBuffer_v2 buffers,
  577. asio::error_code& ec,
  578. typename enable_if<
  579. is_dynamic_buffer_v2<DynamicBuffer_v2>::value
  580. >::type* = 0);
  581. /// Write a certain amount of data to a stream before returning.
  582. /**
  583. * This function is used to write a certain number of bytes of data to a stream.
  584. * The call will block until one of the following conditions is true:
  585. *
  586. * @li All of the data in the supplied dynamic buffer sequence has been written.
  587. *
  588. * @li The completion_condition function object returns 0.
  589. *
  590. * This operation is implemented in terms of zero or more calls to the stream's
  591. * write_some function.
  592. *
  593. * @param s The stream to which the data is to be written. The type must support
  594. * the SyncWriteStream concept.
  595. *
  596. * @param buffers The dynamic buffer sequence from which data will be written.
  597. * Successfully written data is automatically consumed from the buffers.
  598. *
  599. * @param completion_condition The function object to be called to determine
  600. * whether the write operation is complete. The signature of the function object
  601. * must be:
  602. * @code std::size_t completion_condition(
  603. * // Result of latest write_some operation.
  604. * const asio::error_code& error,
  605. *
  606. * // Number of bytes transferred so far.
  607. * std::size_t bytes_transferred
  608. * ); @endcode
  609. * A return value of 0 indicates that the write operation is complete. A
  610. * non-zero return value indicates the maximum number of bytes to be written on
  611. * the next call to the stream's write_some function.
  612. *
  613. * @returns The number of bytes transferred.
  614. *
  615. * @throws asio::system_error Thrown on failure.
  616. */
  617. template <typename SyncWriteStream, typename DynamicBuffer_v2,
  618. typename CompletionCondition>
  619. std::size_t write(SyncWriteStream& s, DynamicBuffer_v2 buffers,
  620. CompletionCondition completion_condition,
  621. typename enable_if<
  622. is_dynamic_buffer_v2<DynamicBuffer_v2>::value
  623. >::type* = 0);
  624. /// Write a certain amount of data to a stream before returning.
  625. /**
  626. * This function is used to write a certain number of bytes of data to a stream.
  627. * The call will block until one of the following conditions is true:
  628. *
  629. * @li All of the data in the supplied dynamic buffer sequence has been written.
  630. *
  631. * @li The completion_condition function object returns 0.
  632. *
  633. * This operation is implemented in terms of zero or more calls to the stream's
  634. * write_some function.
  635. *
  636. * @param s The stream to which the data is to be written. The type must support
  637. * the SyncWriteStream concept.
  638. *
  639. * @param buffers The dynamic buffer sequence from which data will be written.
  640. * Successfully written data is automatically consumed from the buffers.
  641. *
  642. * @param completion_condition The function object to be called to determine
  643. * whether the write operation is complete. The signature of the function object
  644. * must be:
  645. * @code std::size_t completion_condition(
  646. * // Result of latest write_some operation.
  647. * const asio::error_code& error,
  648. *
  649. * // Number of bytes transferred so far.
  650. * std::size_t bytes_transferred
  651. * ); @endcode
  652. * A return value of 0 indicates that the write operation is complete. A
  653. * non-zero return value indicates the maximum number of bytes to be written on
  654. * the next call to the stream's write_some function.
  655. *
  656. * @param ec Set to indicate what error occurred, if any.
  657. *
  658. * @returns The number of bytes written. If an error occurs, returns the total
  659. * number of bytes successfully transferred prior to the error.
  660. */
  661. template <typename SyncWriteStream, typename DynamicBuffer_v2,
  662. typename CompletionCondition>
  663. std::size_t write(SyncWriteStream& s, DynamicBuffer_v2 buffers,
  664. CompletionCondition completion_condition, asio::error_code& ec,
  665. typename enable_if<
  666. is_dynamic_buffer_v2<DynamicBuffer_v2>::value
  667. >::type* = 0);
  668. /*@}*/
  669. /**
  670. * @defgroup async_write asio::async_write
  671. *
  672. * @brief The @c async_write function is a composed asynchronous operation that
  673. * writes a certain amount of data to a stream before completion.
  674. */
  675. /*@{*/
  676. /// Start an asynchronous operation to write all of the supplied data to a
  677. /// stream.
  678. /**
  679. * This function is used to asynchronously write a certain number of bytes of
  680. * data to a stream. The function call always returns immediately. The
  681. * asynchronous operation will continue until one of the following conditions
  682. * is true:
  683. *
  684. * @li All of the data in the supplied buffers has been written. That is, the
  685. * bytes transferred is equal to the sum of the buffer sizes.
  686. *
  687. * @li An error occurred.
  688. *
  689. * This operation is implemented in terms of zero or more calls to the stream's
  690. * async_write_some function, and is known as a <em>composed operation</em>. The
  691. * program must ensure that the stream performs no other write operations (such
  692. * as async_write, the stream's async_write_some function, or any other composed
  693. * operations that perform writes) until this operation completes.
  694. *
  695. * @param s The stream to which the data is to be written. The type must support
  696. * the AsyncWriteStream concept.
  697. *
  698. * @param buffers One or more buffers containing the data to be written.
  699. * Although the buffers object may be copied as necessary, ownership of the
  700. * underlying memory blocks is retained by the caller, which must guarantee
  701. * that they remain valid until the handler is called.
  702. *
  703. * @param handler The handler to be called when the write operation completes.
  704. * Copies will be made of the handler as required. The function signature of
  705. * the handler must be:
  706. * @code void handler(
  707. * const asio::error_code& error, // Result of operation.
  708. *
  709. * std::size_t bytes_transferred // Number of bytes written from the
  710. * // buffers. If an error occurred,
  711. * // this will be less than the sum
  712. * // of the buffer sizes.
  713. * ); @endcode
  714. * Regardless of whether the asynchronous operation completes immediately or
  715. * not, the handler will not be invoked from within this function. On
  716. * immediate completion, invocation of the handler will be performed in a
  717. * manner equivalent to using asio::post().
  718. *
  719. * @par Example
  720. * To write a single data buffer use the @ref buffer function as follows:
  721. * @code
  722. * asio::async_write(s, asio::buffer(data, size), handler);
  723. * @endcode
  724. * See the @ref buffer documentation for information on writing multiple
  725. * buffers in one go, and how to use it with arrays, boost::array or
  726. * std::vector.
  727. */
  728. template <typename AsyncWriteStream, typename ConstBufferSequence,
  729. typename WriteHandler>
  730. ASIO_INITFN_RESULT_TYPE(WriteHandler,
  731. void (asio::error_code, std::size_t))
  732. async_write(AsyncWriteStream& s, const ConstBufferSequence& buffers,
  733. ASIO_MOVE_ARG(WriteHandler) handler,
  734. typename enable_if<
  735. is_const_buffer_sequence<ConstBufferSequence>::value
  736. >::type* = 0);
  737. /// Start an asynchronous operation to write a certain amount of data to a
  738. /// stream.
  739. /**
  740. * This function is used to asynchronously write a certain number of bytes of
  741. * data to a stream. The function call always returns immediately. The
  742. * asynchronous operation will continue until one of the following conditions
  743. * is true:
  744. *
  745. * @li All of the data in the supplied buffers has been written. That is, the
  746. * bytes transferred is equal to the sum of the buffer sizes.
  747. *
  748. * @li The completion_condition function object returns 0.
  749. *
  750. * This operation is implemented in terms of zero or more calls to the stream's
  751. * async_write_some function, and is known as a <em>composed operation</em>. The
  752. * program must ensure that the stream performs no other write operations (such
  753. * as async_write, the stream's async_write_some function, or any other composed
  754. * operations that perform writes) until this operation completes.
  755. *
  756. * @param s The stream to which the data is to be written. The type must support
  757. * the AsyncWriteStream concept.
  758. *
  759. * @param buffers One or more buffers containing the data to be written.
  760. * Although the buffers object may be copied as necessary, ownership of the
  761. * underlying memory blocks is retained by the caller, which must guarantee
  762. * that they remain valid until the handler is called.
  763. *
  764. * @param completion_condition The function object to be called to determine
  765. * whether the write operation is complete. The signature of the function object
  766. * must be:
  767. * @code std::size_t completion_condition(
  768. * // Result of latest async_write_some operation.
  769. * const asio::error_code& error,
  770. *
  771. * // Number of bytes transferred so far.
  772. * std::size_t bytes_transferred
  773. * ); @endcode
  774. * A return value of 0 indicates that the write operation is complete. A
  775. * non-zero return value indicates the maximum number of bytes to be written on
  776. * the next call to the stream's async_write_some function.
  777. *
  778. * @param handler The handler to be called when the write operation completes.
  779. * Copies will be made of the handler as required. The function signature of the
  780. * handler must be:
  781. * @code void handler(
  782. * const asio::error_code& error, // Result of operation.
  783. *
  784. * std::size_t bytes_transferred // Number of bytes written from the
  785. * // buffers. If an error occurred,
  786. * // this will be less than the sum
  787. * // of the buffer sizes.
  788. * ); @endcode
  789. * Regardless of whether the asynchronous operation completes immediately or
  790. * not, the handler will not be invoked from within this function. On
  791. * immediate completion, invocation of the handler will be performed in a
  792. * manner equivalent to using asio::post().
  793. *
  794. * @par Example
  795. * To write a single data buffer use the @ref buffer function as follows:
  796. * @code asio::async_write(s,
  797. * asio::buffer(data, size),
  798. * asio::transfer_at_least(32),
  799. * handler); @endcode
  800. * See the @ref buffer documentation for information on writing multiple
  801. * buffers in one go, and how to use it with arrays, boost::array or
  802. * std::vector.
  803. */
  804. template <typename AsyncWriteStream, typename ConstBufferSequence,
  805. typename CompletionCondition, typename WriteHandler>
  806. ASIO_INITFN_RESULT_TYPE(WriteHandler,
  807. void (asio::error_code, std::size_t))
  808. async_write(AsyncWriteStream& s, const ConstBufferSequence& buffers,
  809. CompletionCondition completion_condition,
  810. ASIO_MOVE_ARG(WriteHandler) handler,
  811. typename enable_if<
  812. is_const_buffer_sequence<ConstBufferSequence>::value
  813. >::type* = 0);
  814. #if !defined(ASIO_NO_DYNAMIC_BUFFER_V1)
  815. /// Start an asynchronous operation to write all of the supplied data to a
  816. /// stream.
  817. /**
  818. * This function is used to asynchronously write a certain number of bytes of
  819. * data to a stream. The function call always returns immediately. The
  820. * asynchronous operation will continue until one of the following conditions
  821. * is true:
  822. *
  823. * @li All of the data in the supplied dynamic buffer sequence has been written.
  824. *
  825. * @li An error occurred.
  826. *
  827. * This operation is implemented in terms of zero or more calls to the stream's
  828. * async_write_some function, and is known as a <em>composed operation</em>. The
  829. * program must ensure that the stream performs no other write operations (such
  830. * as async_write, the stream's async_write_some function, or any other composed
  831. * operations that perform writes) until this operation completes.
  832. *
  833. * @param s The stream to which the data is to be written. The type must support
  834. * the AsyncWriteStream concept.
  835. *
  836. * @param buffers The dynamic buffer sequence from which data will be written.
  837. * Although the buffers object may be copied as necessary, ownership of the
  838. * underlying memory blocks is retained by the caller, which must guarantee
  839. * that they remain valid until the handler is called. Successfully written
  840. * data is automatically consumed from the buffers.
  841. *
  842. * @param handler The handler to be called when the write operation completes.
  843. * Copies will be made of the handler as required. The function signature of the
  844. * handler must be:
  845. * @code void handler(
  846. * const asio::error_code& error, // Result of operation.
  847. *
  848. * std::size_t bytes_transferred // Number of bytes written from the
  849. * // buffers. If an error occurred,
  850. * // this will be less than the sum
  851. * // of the buffer sizes.
  852. * ); @endcode
  853. * Regardless of whether the asynchronous operation completes immediately or
  854. * not, the handler will not be invoked from within this function. On
  855. * immediate completion, invocation of the handler will be performed in a
  856. * manner equivalent to using asio::post().
  857. */
  858. template <typename AsyncWriteStream,
  859. typename DynamicBuffer_v1, typename WriteHandler>
  860. ASIO_INITFN_RESULT_TYPE(WriteHandler,
  861. void (asio::error_code, std::size_t))
  862. async_write(AsyncWriteStream& s,
  863. ASIO_MOVE_ARG(DynamicBuffer_v1) buffers,
  864. ASIO_MOVE_ARG(WriteHandler) handler,
  865. typename enable_if<
  866. is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
  867. && !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
  868. >::type* = 0);
  869. /// Start an asynchronous operation to write a certain amount of data to a
  870. /// stream.
  871. /**
  872. * This function is used to asynchronously write a certain number of bytes of
  873. * data to a stream. The function call always returns immediately. The
  874. * asynchronous operation will continue until one of the following conditions
  875. * is true:
  876. *
  877. * @li All of the data in the supplied dynamic buffer sequence has been written.
  878. *
  879. * @li The completion_condition function object returns 0.
  880. *
  881. * This operation is implemented in terms of zero or more calls to the stream's
  882. * async_write_some function, and is known as a <em>composed operation</em>. The
  883. * program must ensure that the stream performs no other write operations (such
  884. * as async_write, the stream's async_write_some function, or any other composed
  885. * operations that perform writes) until this operation completes.
  886. *
  887. * @param s The stream to which the data is to be written. The type must support
  888. * the AsyncWriteStream concept.
  889. *
  890. * @param buffers The dynamic buffer sequence from which data will be written.
  891. * Although the buffers object may be copied as necessary, ownership of the
  892. * underlying memory blocks is retained by the caller, which must guarantee
  893. * that they remain valid until the handler is called. Successfully written
  894. * data is automatically consumed from the buffers.
  895. *
  896. * @param completion_condition The function object to be called to determine
  897. * whether the write operation is complete. The signature of the function object
  898. * must be:
  899. * @code std::size_t completion_condition(
  900. * // Result of latest async_write_some operation.
  901. * const asio::error_code& error,
  902. *
  903. * // Number of bytes transferred so far.
  904. * std::size_t bytes_transferred
  905. * ); @endcode
  906. * A return value of 0 indicates that the write operation is complete. A
  907. * non-zero return value indicates the maximum number of bytes to be written on
  908. * the next call to the stream's async_write_some function.
  909. *
  910. * @param handler The handler to be called when the write operation completes.
  911. * Copies will be made of the handler as required. The function signature of the
  912. * handler must be:
  913. * @code void handler(
  914. * const asio::error_code& error, // Result of operation.
  915. *
  916. * std::size_t bytes_transferred // Number of bytes written from the
  917. * // buffers. If an error occurred,
  918. * // this will be less than the sum
  919. * // of the buffer sizes.
  920. * ); @endcode
  921. * Regardless of whether the asynchronous operation completes immediately or
  922. * not, the handler will not be invoked from within this function. On
  923. * immediate completion, invocation of the handler will be performed in a
  924. * manner equivalent to using asio::post().
  925. */
  926. template <typename AsyncWriteStream, typename DynamicBuffer_v1,
  927. typename CompletionCondition, typename WriteHandler>
  928. ASIO_INITFN_RESULT_TYPE(WriteHandler,
  929. void (asio::error_code, std::size_t))
  930. async_write(AsyncWriteStream& s,
  931. ASIO_MOVE_ARG(DynamicBuffer_v1) buffers,
  932. CompletionCondition completion_condition,
  933. ASIO_MOVE_ARG(WriteHandler) handler,
  934. typename enable_if<
  935. is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
  936. && !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
  937. >::type* = 0);
  938. #if !defined(ASIO_NO_EXTENSIONS)
  939. #if !defined(ASIO_NO_IOSTREAM)
  940. /// Start an asynchronous operation to write all of the supplied data to a
  941. /// stream.
  942. /**
  943. * This function is used to asynchronously write a certain number of bytes of
  944. * data to a stream. The function call always returns immediately. The
  945. * asynchronous operation will continue until one of the following conditions
  946. * is true:
  947. *
  948. * @li All of the data in the supplied basic_streambuf has been written.
  949. *
  950. * @li An error occurred.
  951. *
  952. * This operation is implemented in terms of zero or more calls to the stream's
  953. * async_write_some function, and is known as a <em>composed operation</em>. The
  954. * program must ensure that the stream performs no other write operations (such
  955. * as async_write, the stream's async_write_some function, or any other composed
  956. * operations that perform writes) until this operation completes.
  957. *
  958. * @param s The stream to which the data is to be written. The type must support
  959. * the AsyncWriteStream concept.
  960. *
  961. * @param b A basic_streambuf object from which data will be written. Ownership
  962. * of the streambuf is retained by the caller, which must guarantee that it
  963. * remains valid until the handler is called.
  964. *
  965. * @param handler The handler to be called when the write operation completes.
  966. * Copies will be made of the handler as required. The function signature of the
  967. * handler must be:
  968. * @code void handler(
  969. * const asio::error_code& error, // Result of operation.
  970. *
  971. * std::size_t bytes_transferred // Number of bytes written from the
  972. * // buffers. If an error occurred,
  973. * // this will be less than the sum
  974. * // of the buffer sizes.
  975. * ); @endcode
  976. * Regardless of whether the asynchronous operation completes immediately or
  977. * not, the handler will not be invoked from within this function. On
  978. * immediate completion, invocation of the handler will be performed in a
  979. * manner equivalent to using asio::post().
  980. */
  981. template <typename AsyncWriteStream, typename Allocator, typename WriteHandler>
  982. ASIO_INITFN_RESULT_TYPE(WriteHandler,
  983. void (asio::error_code, std::size_t))
  984. async_write(AsyncWriteStream& s, basic_streambuf<Allocator>& b,
  985. ASIO_MOVE_ARG(WriteHandler) handler);
  986. /// Start an asynchronous operation to write a certain amount of data to a
  987. /// stream.
  988. /**
  989. * This function is used to asynchronously write a certain number of bytes of
  990. * data to a stream. The function call always returns immediately. The
  991. * asynchronous operation will continue until one of the following conditions
  992. * is true:
  993. *
  994. * @li All of the data in the supplied basic_streambuf has been written.
  995. *
  996. * @li The completion_condition function object returns 0.
  997. *
  998. * This operation is implemented in terms of zero or more calls to the stream's
  999. * async_write_some function, and is known as a <em>composed operation</em>. The
  1000. * program must ensure that the stream performs no other write operations (such
  1001. * as async_write, the stream's async_write_some function, or any other composed
  1002. * operations that perform writes) until this operation completes.
  1003. *
  1004. * @param s The stream to which the data is to be written. The type must support
  1005. * the AsyncWriteStream concept.
  1006. *
  1007. * @param b A basic_streambuf object from which data will be written. Ownership
  1008. * of the streambuf is retained by the caller, which must guarantee that it
  1009. * remains valid until the handler is called.
  1010. *
  1011. * @param completion_condition The function object to be called to determine
  1012. * whether the write operation is complete. The signature of the function object
  1013. * must be:
  1014. * @code std::size_t completion_condition(
  1015. * // Result of latest async_write_some operation.
  1016. * const asio::error_code& error,
  1017. *
  1018. * // Number of bytes transferred so far.
  1019. * std::size_t bytes_transferred
  1020. * ); @endcode
  1021. * A return value of 0 indicates that the write operation is complete. A
  1022. * non-zero return value indicates the maximum number of bytes to be written on
  1023. * the next call to the stream's async_write_some function.
  1024. *
  1025. * @param handler The handler to be called when the write operation completes.
  1026. * Copies will be made of the handler as required. The function signature of the
  1027. * handler must be:
  1028. * @code void handler(
  1029. * const asio::error_code& error, // Result of operation.
  1030. *
  1031. * std::size_t bytes_transferred // Number of bytes written from the
  1032. * // buffers. If an error occurred,
  1033. * // this will be less than the sum
  1034. * // of the buffer sizes.
  1035. * ); @endcode
  1036. * Regardless of whether the asynchronous operation completes immediately or
  1037. * not, the handler will not be invoked from within this function. On
  1038. * immediate completion, invocation of the handler will be performed in a
  1039. * manner equivalent to using asio::post().
  1040. */
  1041. template <typename AsyncWriteStream, typename Allocator,
  1042. typename CompletionCondition, typename WriteHandler>
  1043. ASIO_INITFN_RESULT_TYPE(WriteHandler,
  1044. void (asio::error_code, std::size_t))
  1045. async_write(AsyncWriteStream& s, basic_streambuf<Allocator>& b,
  1046. CompletionCondition completion_condition,
  1047. ASIO_MOVE_ARG(WriteHandler) handler);
  1048. #endif // !defined(ASIO_NO_IOSTREAM)
  1049. #endif // !defined(ASIO_NO_EXTENSIONS)
  1050. #endif // !defined(ASIO_NO_DYNAMIC_BUFFER_V1)
  1051. /// Start an asynchronous operation to write all of the supplied data to a
  1052. /// stream.
  1053. /**
  1054. * This function is used to asynchronously write a certain number of bytes of
  1055. * data to a stream. The function call always returns immediately. The
  1056. * asynchronous operation will continue until one of the following conditions
  1057. * is true:
  1058. *
  1059. * @li All of the data in the supplied dynamic buffer sequence has been written.
  1060. *
  1061. * @li An error occurred.
  1062. *
  1063. * This operation is implemented in terms of zero or more calls to the stream's
  1064. * async_write_some function, and is known as a <em>composed operation</em>. The
  1065. * program must ensure that the stream performs no other write operations (such
  1066. * as async_write, the stream's async_write_some function, or any other composed
  1067. * operations that perform writes) until this operation completes.
  1068. *
  1069. * @param s The stream to which the data is to be written. The type must support
  1070. * the AsyncWriteStream concept.
  1071. *
  1072. * @param buffers The dynamic buffer sequence from which data will be written.
  1073. * Although the buffers object may be copied as necessary, ownership of the
  1074. * underlying memory blocks is retained by the caller, which must guarantee
  1075. * that they remain valid until the handler is called. Successfully written
  1076. * data is automatically consumed from the buffers.
  1077. *
  1078. * @param handler The handler to be called when the write operation completes.
  1079. * Copies will be made of the handler as required. The function signature of the
  1080. * handler must be:
  1081. * @code void handler(
  1082. * const asio::error_code& error, // Result of operation.
  1083. *
  1084. * std::size_t bytes_transferred // Number of bytes written from the
  1085. * // buffers. If an error occurred,
  1086. * // this will be less than the sum
  1087. * // of the buffer sizes.
  1088. * ); @endcode
  1089. * Regardless of whether the asynchronous operation completes immediately or
  1090. * not, the handler will not be invoked from within this function. On
  1091. * immediate completion, invocation of the handler will be performed in a
  1092. * manner equivalent to using asio::post().
  1093. */
  1094. template <typename AsyncWriteStream,
  1095. typename DynamicBuffer_v2, typename WriteHandler>
  1096. ASIO_INITFN_RESULT_TYPE(WriteHandler,
  1097. void (asio::error_code, std::size_t))
  1098. async_write(AsyncWriteStream& s, DynamicBuffer_v2 buffers,
  1099. ASIO_MOVE_ARG(WriteHandler) handler,
  1100. typename enable_if<
  1101. is_dynamic_buffer_v2<DynamicBuffer_v2>::value
  1102. >::type* = 0);
  1103. /// Start an asynchronous operation to write a certain amount of data to a
  1104. /// stream.
  1105. /**
  1106. * This function is used to asynchronously write a certain number of bytes of
  1107. * data to a stream. The function call always returns immediately. The
  1108. * asynchronous operation will continue until one of the following conditions
  1109. * is true:
  1110. *
  1111. * @li All of the data in the supplied dynamic buffer sequence has been written.
  1112. *
  1113. * @li The completion_condition function object returns 0.
  1114. *
  1115. * This operation is implemented in terms of zero or more calls to the stream's
  1116. * async_write_some function, and is known as a <em>composed operation</em>. The
  1117. * program must ensure that the stream performs no other write operations (such
  1118. * as async_write, the stream's async_write_some function, or any other composed
  1119. * operations that perform writes) until this operation completes.
  1120. *
  1121. * @param s The stream to which the data is to be written. The type must support
  1122. * the AsyncWriteStream concept.
  1123. *
  1124. * @param buffers The dynamic buffer sequence from which data will be written.
  1125. * Although the buffers object may be copied as necessary, ownership of the
  1126. * underlying memory blocks is retained by the caller, which must guarantee
  1127. * that they remain valid until the handler is called. Successfully written
  1128. * data is automatically consumed from the buffers.
  1129. *
  1130. * @param completion_condition The function object to be called to determine
  1131. * whether the write operation is complete. The signature of the function object
  1132. * must be:
  1133. * @code std::size_t completion_condition(
  1134. * // Result of latest async_write_some operation.
  1135. * const asio::error_code& error,
  1136. *
  1137. * // Number of bytes transferred so far.
  1138. * std::size_t bytes_transferred
  1139. * ); @endcode
  1140. * A return value of 0 indicates that the write operation is complete. A
  1141. * non-zero return value indicates the maximum number of bytes to be written on
  1142. * the next call to the stream's async_write_some function.
  1143. *
  1144. * @param handler The handler to be called when the write operation completes.
  1145. * Copies will be made of the handler as required. The function signature of the
  1146. * handler must be:
  1147. * @code void handler(
  1148. * const asio::error_code& error, // Result of operation.
  1149. *
  1150. * std::size_t bytes_transferred // Number of bytes written from the
  1151. * // buffers. If an error occurred,
  1152. * // this will be less than the sum
  1153. * // of the buffer sizes.
  1154. * ); @endcode
  1155. * Regardless of whether the asynchronous operation completes immediately or
  1156. * not, the handler will not be invoked from within this function. On
  1157. * immediate completion, invocation of the handler will be performed in a
  1158. * manner equivalent to using asio::post().
  1159. */
  1160. template <typename AsyncWriteStream, typename DynamicBuffer_v2,
  1161. typename CompletionCondition, typename WriteHandler>
  1162. ASIO_INITFN_RESULT_TYPE(WriteHandler,
  1163. void (asio::error_code, std::size_t))
  1164. async_write(AsyncWriteStream& s, DynamicBuffer_v2 buffers,
  1165. CompletionCondition completion_condition,
  1166. ASIO_MOVE_ARG(WriteHandler) handler,
  1167. typename enable_if<
  1168. is_dynamic_buffer_v2<DynamicBuffer_v2>::value
  1169. >::type* = 0);
  1170. /*@}*/
  1171. } // namespace asio
  1172. #include "asio/detail/pop_options.hpp"
  1173. #include "asio/impl/write.hpp"
  1174. #endif // ASIO_WRITE_HPP