net_ts.qbk 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. [/
  2. / Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  3. /
  4. / Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. /]
  7. [section:net_ts Networking TS compatibility]
  8. Boost.Asio now provides the interfaces and functionality specified by the "C++
  9. Extensions for Networking" Technical Specification. In addition to access via
  10. the usual Boost.Asio header files, this functionality may be accessed through special
  11. headers that correspond to the header files defined in the TS. These are listed
  12. in the table below:
  13. [table
  14. [[Networking TS header][Boost.Asio header]]
  15. [[`#include <buffer>`][`#include <boost/asio/ts/buffer.hpp>`]]
  16. [[`#include <executor>`][`#include <boost/asio/ts/executor.hpp>`]]
  17. [[`#include <internet>`][`#include <boost/asio/ts/internet.hpp>`]]
  18. [[`#include <io_context>`][`#include <boost/asio/ts/io_context.hpp>`]]
  19. [[`#include <net>`][`#include <boost/asio/ts/net.hpp>`]]
  20. [[`#include <netfwd>`][`#include <boost/asio/ts/netfwd.hpp>`]]
  21. [[`#include <socket>`][`#include <boost/asio/ts/socket.hpp>`]]
  22. [[`#include <timer>`][`#include <boost/asio/ts/timer.hpp>`]]
  23. ]
  24. In some cases the new Networking TS compatible interfaces supersede older Boost.Asio
  25. facilities. In these cases the older interfaces have been deprecated. The table
  26. below shows the new Networking TS interfaces and the facilities they replace:
  27. [table
  28. [[New interface][Old interface][Notes]]
  29. [
  30. [[link boost_asio.reference.io_context `io_context`]]
  31. [[link boost_asio.reference.io_service `io_service`]]
  32. [The name `io_service` is retained as a typedef.]
  33. ]
  34. [
  35. [[link boost_asio.reference.dispatch `dispatch`]]
  36. [[link boost_asio.reference.io_context.dispatch `io_service::dispatch`]]
  37. [The `dispatch` free function can be used to submit functions to any [link
  38. boost_asio.reference.Executor1 Executor] or [link boost_asio.reference.ExecutionContext
  39. ExecutionContext].]
  40. ]
  41. [
  42. [[link boost_asio.reference.dispatch `post`]]
  43. [[link boost_asio.reference.io_context.post `io_service::post`]]
  44. [The `dispatch` free function can be used to submit functions to any [link
  45. boost_asio.reference.Executor1 Executor] or [link boost_asio.reference.ExecutionContext
  46. ExecutionContext].]
  47. ]
  48. [
  49. [[link boost_asio.reference.dispatch `defer`]]
  50. [[link boost_asio.reference.io_context.post `io_service::post`] when the [link
  51. boost_asio.reference.asio_handler_is_continuation `asio_handler_is_continuation`]
  52. hook returns true]
  53. [The `defer` free function can be used to submit functions to any [link
  54. boost_asio.reference.Executor1 Executor] or [link boost_asio.reference.ExecutionContext
  55. ExecutionContext].]
  56. ]
  57. [
  58. [[link boost_asio.reference.io_context.poll `io_context::poll`]]
  59. [[link boost_asio.reference.io_context.poll `io_service::poll`] overload that
  60. takes `error_code&`]
  61. [The `error_code` overload is not required.]
  62. ]
  63. [
  64. [[link boost_asio.reference.io_context.poll_one `io_context::poll_one`]]
  65. [[link boost_asio.reference.io_context.poll_one `io_service::poll_one`] overload
  66. that takes `error_code&`]
  67. [The `error_code` overload is not required.]
  68. ]
  69. [
  70. [[link boost_asio.reference.io_context.run `io_context::run`]]
  71. [[link boost_asio.reference.io_context.run `io_service::run`] overload that takes
  72. `error_code&`]
  73. [The `error_code` overload is not required.]
  74. ]
  75. [
  76. [[link boost_asio.reference.io_context.run_one `io_context::run_one`]]
  77. [[link boost_asio.reference.io_context.run_one `io_service::run_one`] overload
  78. that takes `error_code&`]
  79. [The `error_code` overload is not required.]
  80. ]
  81. [
  82. [[link boost_asio.reference.io_context.run_for `io_context::run_for`],
  83. [link boost_asio.reference.io_context.run_until `io_context::run_until`],
  84. [link boost_asio.reference.io_context.run_one_for `io_context::run_one_for`], and
  85. [link boost_asio.reference.io_context.run_one_until `io_context::run_one_until`]]
  86. []
  87. [These functions add the ability to run an `io_context` for a limited time.]
  88. ]
  89. [
  90. [[link boost_asio.reference.io_context.restart `io_context::restart`]]
  91. [[link boost_asio.reference.io_context.reset `io_service::reset`]]
  92. []
  93. ]
  94. [
  95. [[link boost_asio.reference.io_context.io_context `io_context`] constructor
  96. `concurrency_hint` parameter is type `int`]
  97. [[link boost_asio.reference.io_context.io_context `io_context`] constructor
  98. `concurrency_hint` parameter is type `std::size_t`]
  99. [The old constructor has not been retained as a deprecated overload.]
  100. ]
  101. [
  102. [[link boost_asio.reference.execution_context `execution_context`], [link
  103. boost_asio.reference.execution_context__service `execution_context::service`],
  104. and [link boost_asio.reference.execution_context__id `execution_context::id`]]
  105. [[link boost_asio.reference.io_context `io_service`], [link
  106. boost_asio.reference.io_context__service `io_service::service`], and [link
  107. boost_asio.reference.execution_context__id `io_service::id`]]
  108. [The service-related functionality has been moved to the
  109. `execution_context` base class. This may also be used as a base for
  110. creating custom execution contexts.]
  111. ]
  112. [
  113. [[link boost_asio.reference.execution_context.make_service `make_service`]]
  114. [[link boost_asio.reference.execution_context.add_service `add_service`]]
  115. []
  116. ]
  117. [
  118. [[link boost_asio.reference.strand `strand`]]
  119. [[link boost_asio.reference.io_context__strand `io_service::strand`]]
  120. [This template works with any valid executor, and is itself a valid
  121. executor.]
  122. ]
  123. [
  124. [[link boost_asio.reference.executor_work_guard `executor_work_guard`] and [link
  125. boost_asio.reference.make_work_guard `make_work_guard`]]
  126. [[link boost_asio.reference.io_context__work `io_service::work`]]
  127. [Work tracking is now covered by the [link boost_asio.reference.Executor1
  128. Executor] requirements. These templates work with any valid executor.]
  129. ]
  130. [
  131. [[link boost_asio.reference.executor_binder `executor_binder`] and [link
  132. boost_asio.reference.bind_executor `bind_executor`]]
  133. [[link boost_asio.reference.io_context.wrap `io_service::wrap`] and
  134. [link boost_asio.reference.io_context__strand.wrap `io_service::strand::wrap`]]
  135. [These templates work with any valid executor.]
  136. ]
  137. [
  138. [[link boost_asio.reference.async_result `async_result`] with `CompletionToken`
  139. and `Signature` template parameters]
  140. [`handler_type` and single parameter `async_result`]
  141. [The `async_result` trait is now the single point of customisation for
  142. asynchronous operation completion handlers and return type.]
  143. ]
  144. [
  145. [[link boost_asio.reference.associated_executor `associated_executor`] and [link
  146. boost_asio.reference.get_associated_executor `get_associated_executor`]]
  147. [[link boost_asio.reference.asio_handler_invoke `asio_handler_invoke`]]
  148. [The handler invocation hook has been replaced by the new [link
  149. boost_asio.reference.Executor1 Executor] requirements and the associated executor
  150. traits.]
  151. ]
  152. [
  153. [[link boost_asio.reference.associated_allocator `associated_allocator`] and
  154. [link boost_asio.reference.get_associated_allocator `get_associated_allocator`]]
  155. [[link boost_asio.reference.asio_handler_allocate `asio_handler_allocate`] and
  156. [link boost_asio.reference.asio_handler_deallocate `asio_handler_deallocate`]]
  157. [The handler allocation hooks have been replaced by the standard Allocator
  158. requirements and the associated allocator traits.]
  159. ]
  160. [
  161. [[link boost_asio.reference.const_buffer.data `const_buffer::data`] and [link
  162. boost_asio.reference.mutable_buffer.data `mutable_buffer::data`]]
  163. [[link boost_asio.reference.buffer_cast `buffer_cast`]]
  164. []
  165. ]
  166. [
  167. [[link boost_asio.reference.const_buffer.size `const_buffer::size`] and [link
  168. boost_asio.reference.mutable_buffer.size `mutable_buffer::size`]]
  169. [[link boost_asio.reference.buffer_size `buffer_size`] for single buffers]
  170. [`buffer_size` is not deprecated for single buffers as `const_buffer` and
  171. `mutable_buffer` now satisfy the buffer sequence requirements]
  172. ]
  173. [
  174. [[link boost_asio.reference.const_buffer `const_buffer`]]
  175. [[link boost_asio.reference.const_buffers_1 `const_buffers_1`]]
  176. [The [link boost_asio.reference.ConstBufferSequence ConstBufferSequence]
  177. requirements have been modified such that `const_buffer` now satisfies
  178. them.]
  179. ]
  180. [
  181. [[link boost_asio.reference.mutable_buffer `mutable_buffer`]]
  182. [[link boost_asio.reference.mutable_buffers_1 `mutable_buffers_1`]]
  183. [The [link boost_asio.reference.MutableBufferSequence MutableBufferSequence]
  184. requirements have been modified such that `mutable_buffer` now satisfies
  185. them.]
  186. ]
  187. [
  188. [[link boost_asio.reference.basic_socket.get_executor
  189. `basic_socket::get_executor`] (and corresponding member for I/O objects
  190. such as timers, serial ports, etc.)]
  191. [[link boost_asio.reference.basic_io_object.get_io_service
  192. `basic_io_object::get_io_service`]]
  193. [Use `get_executor().context()` to obtain the associated `io_context`.]
  194. ]
  195. [
  196. [[link boost_asio.reference.socket_base.max_listen_connections
  197. `socket_base::max_listen_connections`]]
  198. [[link boost_asio.reference.socket_base.max_connections
  199. `socket_base::max_connections`]]
  200. []
  201. ]
  202. [
  203. [[link boost_asio.reference.socket_base.wait_type `socket_base::wait_type`],
  204. [link boost_asio.reference.basic_socket.wait `basic_socket::wait`], [link
  205. boost_asio.reference.basic_socket.async_wait `basic_socket::async_wait`], [link
  206. boost_asio.reference.basic_socket_acceptor.wait `basic_socket_acceptor::wait`],
  207. and [link boost_asio.reference.basic_socket_acceptor.async_wait
  208. `basic_socket_acceptor::async_wait`]]
  209. [[link boost_asio.reference.null_buffers `null_buffers`]]
  210. [Operations for reactive I/O.]
  211. ]
  212. [
  213. [[link boost_asio.reference.basic_socket_acceptor.accept
  214. `basic_socket_acceptor::accept`] returns a socket]
  215. [[link boost_asio.reference.basic_socket_acceptor.accept
  216. `basic_socket_acceptor::accept`] takes a socket by reference]
  217. [Uses move support so requires C++11 or later. To accept a connection into
  218. a socket object on a different `io_context`, pass the destination context
  219. to `accept`.]
  220. ]
  221. [
  222. [[link boost_asio.reference.basic_socket_acceptor.async_accept
  223. `basic_socket_acceptor::async_accept`] passes socket to handler]
  224. [[link boost_asio.reference.basic_socket_acceptor.async_accept
  225. `basic_socket_acceptor::async_accept`] takes a socket by reference]
  226. [Uses move support so requires C++11 or later. To accept a connection into
  227. a socket object on a different `io_context`, pass the destination context
  228. to `async_accept`.]
  229. ]
  230. [
  231. [[link boost_asio.reference.connect `connect`] overloads that take a range]
  232. [[link boost_asio.reference.connect `connect`] overloads that take a single
  233. iterator]
  234. [The [link boost_asio.reference.ip__basic_resolver.resolve
  235. `ip::basic_resolver::resolve`] function now returns a range. When the
  236. `resolve` function's result is passed directly to `connect`, the range
  237. overload will be selected.]
  238. ]
  239. [
  240. [[link boost_asio.reference.async_connect `async_connect`] overloads that take a
  241. range]
  242. [[link boost_asio.reference.async_connect `async_connect`] overloads that take a
  243. single iterator]
  244. [The [link boost_asio.reference.ip__basic_resolver.resolve
  245. `ip::basic_resolver::resolve`] function now returns a range. When the
  246. `resolve` function's result is passed directly to `async_connect`, the
  247. range overload will be selected.]
  248. ]
  249. [
  250. [[link boost_asio.reference.basic_socket_streambuf.duration
  251. `basic_socket_streambuf::duration`]]
  252. [[link boost_asio.reference.basic_socket_streambuf.duration_type
  253. `basic_socket_streambuf::duration_type`]]
  254. []
  255. ]
  256. [
  257. [[link boost_asio.reference.basic_socket_streambuf.time_point
  258. `basic_socket_streambuf::time_point`]]
  259. [[link boost_asio.reference.basic_socket_streambuf.time_type
  260. `basic_socket_streambuf::time_type`]]
  261. []
  262. ]
  263. [
  264. [[link boost_asio.reference.basic_socket_streambuf.expiry
  265. `basic_socket_streambuf::expiry`]]
  266. [[link boost_asio.reference.basic_socket_streambuf.expires_at
  267. `basic_socket_streambuf::expires_at`] and [link
  268. boost_asio.reference.basic_socket_streambuf.expires_from_now
  269. `basic_socket_streambuf::expires_from_now`] getters]
  270. []
  271. ]
  272. [
  273. [[link boost_asio.reference.basic_socket_streambuf.expires_after
  274. `basic_socket_streambuf::expires_after`]]
  275. [[link boost_asio.reference.basic_socket_streambuf.expires_from_now
  276. `basic_socket_streambuf::expires_from_now`] setter]
  277. []
  278. ]
  279. [
  280. [[link boost_asio.reference.basic_socket_streambuf.error
  281. `basic_socket_streambuf::error`]]
  282. [[link boost_asio.reference.basic_socket_streambuf.puberror
  283. `basic_socket_streambuf::puberror`]]
  284. []
  285. ]
  286. [
  287. [[link boost_asio.reference.basic_socket_iostream.duration
  288. `basic_socket_iostream::duration`]]
  289. [[link boost_asio.reference.basic_socket_iostream.duration_type
  290. `basic_socket_iostream::duration_type`]]
  291. []
  292. ]
  293. [
  294. [[link boost_asio.reference.basic_socket_iostream.time_point
  295. `basic_socket_iostream::time_point`]]
  296. [[link boost_asio.reference.basic_socket_iostream.time_type
  297. `basic_socket_iostream::time_type`]]
  298. []
  299. ]
  300. [
  301. [[link boost_asio.reference.basic_socket_iostream.expiry
  302. `basic_socket_iostream::expiry`]]
  303. [[link boost_asio.reference.basic_socket_iostream.expires_at
  304. `basic_socket_iostream::expires_at`] and [link
  305. boost_asio.reference.basic_socket_iostream.expires_from_now
  306. `basic_socket_iostream::expires_from_now`] getters]
  307. []
  308. ]
  309. [
  310. [[link boost_asio.reference.basic_socket_iostream.expires_after
  311. `basic_socket_iostream::expires_after`]]
  312. [[link boost_asio.reference.basic_socket_iostream.expires_from_now
  313. `basic_socket_iostream::expires_from_now`] setter]
  314. []
  315. ]
  316. [
  317. [[link boost_asio.reference.basic_waitable_timer.cancel
  318. `basic_waitable_timer::cancel`]]
  319. [[link boost_asio.reference.basic_waitable_timer.cancel
  320. `basic_waitable_timer::cancel`] overload that takes `error_code&`]
  321. [The `error_code` overload is not required.]
  322. ]
  323. [
  324. [[link boost_asio.reference.basic_waitable_timer.cancel_one
  325. `basic_waitable_timer::cancel_one`]]
  326. [[link boost_asio.reference.basic_waitable_timer.cancel_one
  327. `basic_waitable_timer::cancel_one`] overload that takes `error_code&`]
  328. [The `error_code` overload is not required.]
  329. ]
  330. [
  331. [[link boost_asio.reference.basic_waitable_timer.expires_at
  332. `basic_waitable_timer::expires_at`] setter]
  333. [[link boost_asio.reference.basic_waitable_timer.expires_at
  334. `basic_waitable_timer::expires_at`] setter that takes `error_code&`]
  335. [The `error_code` overload is not required.]
  336. ]
  337. [
  338. [[link boost_asio.reference.basic_waitable_timer.expiry
  339. `basic_waitable_timer::expiry`]]
  340. [[link boost_asio.reference.basic_waitable_timer.expires_at
  341. `basic_waitable_timer::expires_at`] and [link
  342. boost_asio.reference.basic_waitable_timer.expires_from_now
  343. `basic_waitable_timer::expires_from_now`] getters]
  344. []
  345. ]
  346. [
  347. [[link boost_asio.reference.basic_waitable_timer.expires_after
  348. `basic_waitable_timer::expires_after`]]
  349. [[link boost_asio.reference.basic_waitable_timer.expires_from_now
  350. `basic_waitable_timer::expires_from_now`] setter]
  351. []
  352. ]
  353. [
  354. [[link boost_asio.reference.ip__address.make_address `ip::make_address`]]
  355. [[link boost_asio.reference.ip__address.from_string `ip::address::from_string`]]
  356. []
  357. ]
  358. [
  359. [[link boost_asio.reference.ip__address_v4.make_address_v4 `ip::make_address_v4`]]
  360. [[link boost_asio.reference.ip__address_v4.from_string
  361. `ip::address_v4::from_string`] and [link
  362. boost_asio.reference.ip__address_v6.to_v4 `ip::address_v6::to_v4`]]
  363. []
  364. ]
  365. [
  366. [[link boost_asio.reference.ip__address_v6.make_address_v6 `ip::make_address_v6`]]
  367. [[link boost_asio.reference.ip__address_v6.from_string
  368. `ip::address_v6::from_string`] and [link
  369. boost_asio.reference.ip__address_v6.v4_mapped `ip::address_v6::v4_mapped`]]
  370. []
  371. ]
  372. [
  373. [[link boost_asio.reference.ip__address.to_string `ip::address::to_string`]]
  374. [[link boost_asio.reference.ip__address.to_string `ip::address::to_string`] that
  375. takes `error_code&`]
  376. [The `error_code` overload is not required.]
  377. ]
  378. [
  379. [[link boost_asio.reference.ip__address_v4.to_string `ip::address_v4::to_string`]]
  380. [[link boost_asio.reference.ip__address_v4.to_string `ip::address_v4::to_string`]
  381. that takes `error_code&`]
  382. [The `error_code` overload is not required.]
  383. ]
  384. [
  385. [[link boost_asio.reference.ip__address_v6.to_string `ip::address_v6::to_string`]]
  386. [[link boost_asio.reference.ip__address_v6.to_string `ip::address_v6::to_string`]
  387. that takes `error_code&`]
  388. [The `error_code` overload is not required.]
  389. ]
  390. [
  391. [No replacement]
  392. [[link boost_asio.reference.ip__address_v6.is_v4_compatible
  393. `ip::address_v6::is_v4_compatible`] and [link
  394. boost_asio.reference.ip__address_v6.v4_compatible
  395. `ip::address_v6::v4_compatible`]]
  396. []
  397. ]
  398. [
  399. [[link boost_asio.reference.ip__network_v4 `ip::network_v4`]]
  400. [[link boost_asio.reference.ip__address_v4.broadcast `ip::address_v4::broadcast`],
  401. [link boost_asio.reference.ip__address_v4.is_class_a `ip::address_v4::is_class_a`],
  402. [link boost_asio.reference.ip__address_v4.is_class_b `ip::address_v4::is_class_b`],
  403. [link boost_asio.reference.ip__address_v4.is_class_c `ip::address_v4::is_class_c`],
  404. and [link boost_asio.reference.ip__address_v4.netmask `ip::address_v4::netmask`]]
  405. [The `network_v4` class adds the ability to manipulate IPv4 network
  406. addresses using CIDR notation.]
  407. ]
  408. [
  409. [[link boost_asio.reference.ip__network_v6 `ip::network_v6`]]
  410. []
  411. [The `network_v6` class adds the ability to manipulate IPv6 network
  412. addresses using CIDR notation.]
  413. ]
  414. [
  415. [[link boost_asio.reference.ip__basic_address_iterator_lt__address_v4__gt_
  416. `ip::address_v4_iterator`] and [link
  417. boost_asio.reference.ip__basic_address_range_lt__address_v4__gt_
  418. `ip::address_v4_range`]]
  419. []
  420. [The `ip::address_v4_iterator` and `address_v4_range` classes add the
  421. ability to iterate over all, or a subset of, IPv4 addresses.]
  422. ]
  423. [
  424. [[link boost_asio.reference.ip__basic_address_iterator_lt__address_v6__gt_
  425. `ip::address_v6_iterator`] and [link
  426. boost_asio.reference.ip__basic_address_range_lt__address_v6__gt_
  427. `ip::address_v6_range`]]
  428. []
  429. [The `ip::address_v6_iterator` and `address_v6_range` classes add the
  430. ability to iterate over all, or a subset of, IPv6 addresses.]
  431. ]
  432. [
  433. [[link boost_asio.reference.ip__basic_resolver.results_type
  434. `ip::basic_resolver::results_type`]]
  435. [[link boost_asio.reference.ip__basic_resolver.iterator
  436. `ip::basic_resolver::iterator`]]
  437. [Resolvers now produce ranges rather than single iterators.]
  438. ]
  439. [
  440. [[link boost_asio.reference.ip__basic_resolver.resolve
  441. `ip::basic_resolver::resolve`] overloads taking hostname and service as
  442. arguments]
  443. [[link boost_asio.reference.ip__basic_resolver.resolve
  444. `ip::basic_resolver::resolve`] overloads taking a [link
  445. boost_asio.reference.ip__basic_resolver.query `ip::basic_resolver::query`]]
  446. []
  447. ]
  448. [
  449. [[link boost_asio.reference.ip__basic_resolver.resolve
  450. `ip::basic_resolver::resolve`] returns a range]
  451. [[link boost_asio.reference.ip__basic_resolver.resolve
  452. `ip::basic_resolver::resolve`] returns a single iterator]
  453. []
  454. ]
  455. [
  456. [[link boost_asio.reference.ip__basic_resolver.async_resolve
  457. `ip::basic_resolver::async_resolve`] overloads taking hostname and service
  458. as arguments]
  459. [[link boost_asio.reference.ip__basic_resolver.async_resolve
  460. `ip::basic_resolver::async_resolve`] overloads taking a [link
  461. boost_asio.reference.ip__basic_resolver.query `ip::basic_resolver::query`]]
  462. []
  463. ]
  464. [
  465. [[link boost_asio.reference.ip__basic_resolver.async_resolve
  466. `ip::basic_resolver::async_resolve`] calls the handler with a range]
  467. [[link boost_asio.reference.ip__basic_resolver.async_resolve
  468. `ip::basic_resolver::async_resolve`] calls the handler with a single
  469. iterator]
  470. []
  471. ]
  472. ]
  473. [endsect]