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