Commit Graph

63 Commits

Author SHA1 Message Date
Christopher Kohlhoff
2f7af2e33c Update composed operations examples to use async_initiate and a new helper function async_compose. 2019-03-06 20:22:23 +11:00
Christopher Kohlhoff
9eb153718d Add a make_strand function.
The make_strand function creates a strand with a deduced Executor template
argument.
2019-03-02 16:02:42 +11:00
Christopher Kohlhoff
baca9a092f Promote coroutines TS support classes to asio namespace.
The awaitable<>, co_spawn(), this_coro, detached, and redirect_error
facilities have been moved from the asio::experimental namespace to
namespace asio. As part of this change, the this_coro::token() awaitable
has been superseded by the asio::use_awaitable completion token.

Please note that the use_awaitable and redirect_error completion tokens
work only with asynchronous operations that use the new form of
async_result with member function initiate(). Furthermore, when using
use_awaitable, please be aware that the asynchronous operation is not
initiated until co_await is applied to the awaitable<>.
2019-02-28 00:02:00 +11:00
Christopher Kohlhoff
ae04c26689 Update copyright notices. 2019-02-17 19:59:39 -10:00
Christopher Kohlhoff
59066d80b2 Add custom I/O executor support to I/O objects.
All I/O objects now have an additional Executor template parameter. This
template parameter defaults to the asio::executor type (the polymorphic
executor wrapper) but can be used to specify a user-defined executor
type.

I/O objects' constructors and functions that previously took an
asio::io_context& now accept either an Executor or a reference to a
concrete ExecutionContext (such as asio::io_context or
asio::thread_pool).

One potential point of breakage in existing user code is when reusing an
I/O object's io_context for constructing another I/O object, as in:

    asio::steady_timer my_timer(my_socket.get_executor().context());

To fix this, either construct the second I/O object using the first I/O
object's executor:

    asio::steady_timer my_timer(my_socket.get_executor());

or otherwise explicitly pass the io_context:

    asio::steady_timer my_timer(my_io_context);
2019-02-17 19:59:29 -10:00
Christopher Kohlhoff
0b2db4b84e Remove deprecated services support. 2019-02-17 19:59:01 -10:00
Christopher Kohlhoff
41fbd65fc7 Need to link boost.chrono in tests and C++03 examples. 2018-04-03 19:41:26 +10:00
Christopher Kohlhoff
d23cb643d9 Fix cross-compilation support. 2018-04-01 21:45:55 +10:00
Christopher Kohlhoff
886839cf55 Update copyright notices. 2018-03-04 21:59:30 +11:00
Christopher Kohlhoff
077ed86047 Add headers for TS compatibility. 2017-12-02 10:23:24 +11:00
Christopher Kohlhoff
2bfd4d24d0 Make sure asio/system_context.hpp is self-contained. 2017-12-02 09:03:14 +11:00
Christopher Kohlhoff
b60e92b13e Initial merge of Networking TS compatibility.
Merged from chriskohlhoff/asio master branch as of commit
4a4d28b0d24c53236e229bd1b5f378c9964b1ebb.
2017-10-23 21:48:43 +11:00
Christopher Kohlhoff
f7fa336c91 Update copyright notices. 2017-03-05 22:43:47 +11:00
Christopher Kohlhoff
36eef63a9c Update copyright notices. 2016-09-11 11:35:40 +10:00
Jessica Hamilton
df50982934 Haiku: link to libnetwork 2015-12-10 22:45:24 +11:00
Christopher Kohlhoff
41bf42b8da Update copyright notices. 2015-03-20 00:14:19 +11:00
Christopher Kohlhoff
3e2e9c8f97 Remove dependency on Boost.Test. 2015-03-20 00:04:57 +11:00
Christopher Kohlhoff
28f690f504 Update copyright notices. 2014-05-03 09:25:39 +10:00
Christopher Kohlhoff
50fa08dbdc Change unit tests so that they don't depend on Boost.Thread.
[SVN r85800]
2013-09-20 12:04:00 +00:00
Christopher Kohlhoff
abd9cdb60f Add generic socket protocols and converting move constructors.
Four new protocol classes have been added:

- asio::generic::datagram_protocol
- asio::generic::raw_protocol
- asio::generic::seq_packet_protocol
- asio::generic::stream_protocol

These classes implement the Protocol type requirements, but allow the
user to specify the address family (e.g. AF_INET) and protocol type
(e.g. IPPROTO_TCP) at runtime.

A new endpoint class template, asio::generic::basic_endpoint, has been
added to support these new protocol classes. This endpoint can hold any
other endpoint type, provided its native representation fits into a
sockaddr_storage object.

When using C++11, it is now possible to perform move construction from a
socket (or acceptor) object to convert to the more generic protocol's
socket (or acceptor) type. If the protocol conversion is valid:

  Protocol1 p1 = ...;
  Protocol2 p2(p1);

then the corresponding socket conversion is allowed:

  Protocol1::socket socket1(io_service);
  ...
  Protocol2::socket socket2(std::move(socket1));

For example, one possible conversion is from a TCP socket to a generic
stream-oriented socket:

  asio::ip::tcp::socket socket1(io_service);
  ...
  asio::generic::stream_protocol::socket socket2(std::move(socket1));

The conversion is also available for move-assignment. Note that these
conversions are not limited to the newly added generic protocol classes.
User-defined protocols may take advantage of this feature by similarly
ensuring the conversion from Protocol1 to Protocol2 is valid, as above.

As a convenience, the socket acceptor's accept() and async_accept()
functions have been changed so that they can directly accept into a
different protocol's socket type, provided the protocol conversion is
valid. For example, the following is now possible:

  asio::ip::tcp::acceptor acceptor(io_service);
  ...
  asio::generic::stream_protocol::socket socket1(io_service);
  acceptor.accept(socket1);


[SVN r84363]
2013-05-19 04:55:11 +00:00
Christopher Kohlhoff
280a7d55b3 Remove the stackless coroutine class and macros from the HTTP server 4
example, and instead make them a part of Asio's documented interface.


[SVN r84346]
2013-05-18 11:54:59 +00:00
Christopher Kohlhoff
95d16d75b7 Update copyright notices.
[SVN r84345]
2013-05-18 11:24:59 +00:00
Christopher Kohlhoff
be0221203a Add new traits classes, handler_type and async_result, that allow
the customisation of the return type of an initiating function.


[SVN r84308]
2013-05-16 23:26:04 +00:00
Christopher Kohlhoff
30f3e430a7 Update copyright notices.
[SVN r76420]
2012-01-11 23:04:08 +00:00
Christopher Kohlhoff
81f394e29d Added object_handle support.
[SVN r76397]
2012-01-10 09:58:05 +00:00
Christopher Kohlhoff
40316dfdb4 Chrono support.
[SVN r76380]
2012-01-09 13:43:38 +00:00
Christopher Kohlhoff
f064021b6d Changes for asio version 1.5.1:
* Added support for signal handling, using a new class called
  signal_set. Programs may add one or more signals to the set, and then
  perform an async_wait() operation. The specified handler will be
  called when one of the signals occurs. The same signal number may
  registered with multiple signal_set objects, however the signal number
  must be used only with Asio.

* Added handler tracking, a new debugging aid. When enabled by defining
  BOOST_ASIO_ENABLE_HANDLER_TRACKING, Asio writes debugging output to
  the standard error stream. The output records asynchronous operations
  and the relationships between their handlers. It may be post-processed
  using the included [^handlerviz.pl] tool to create a visual
  representation of the handlers (requires GraphViz).

* Fixed a bug in asio::streambuf where the consume() function did not
  always update the internal buffer pointers correctly. The problem may
  occur when the asio::streambuf is filled with data using the standard
  C++ member functions such as sputn(). (Note: the problem does not
  manifest when the streambuf is populated by the Asio free functions
  read(), async_read(), read_until() or async_read_until().)

* Fixed a bug on kqueue-based platforms, where reactor read operations
  that return false from their perform() function are not correctly
  re-registered with kqueue.

* Modified the buffers_iterator<> and ip::basic_resolver_iterator
  classes so that the value_type typedefs are non-const byte types.


[SVN r69198]
2011-02-23 01:42:40 +00:00
Christopher Kohlhoff
7139b456d2 Changes for asio version 1.5.0:
* Added support for timeouts on socket iostreams, such as
  ip::tcp::iostream. A timeout is set by calling expires_at() or
  expires_from_now() to establish a deadline. Any socket operations
  which occur past the deadline will put the iostream into a bad state.

* Added a new error() member function to socket iostreams, for
  retrieving the error code from the most recent system call.

* Added a new basic_deadline_timer::cancel_one() function. This function
  lets you cancel a single waiting handler on a timer. Handlers are
  cancelled in FIFO order.

* Added a new transfer_exactly() completion condition. This can be used
  to send or receive a specified number of bytes even if the total size
  of the buffer (or buffer sequence) is larger.

* Added new free functions connect() and async_connect(). These
  operations try each endpoint in a list until the socket is
  successfully connected.

* Extended the buffer_size() function so that it works for buffer
  sequences in addition to individual buffers.

* Added a new buffer_copy() function that can be used to copy the raw
  bytes between individual buffers and buffer sequences.

* Added new non-throwing overloads of read(), read_at(), write() and
  write_at() that do not require a completion condition.

* Added friendlier compiler errors for when a completion handler does
  not meet the necessary type requirements. When C++0x is available
  (currently supported for g++ 4.5 or later, and MSVC 10), static_assert
  is also used to generate an informative error message. Checking may be
  disabled by defining BOOST_ASIO_DISABLE_HANDLER_TYPE_REQUIREMENTS.

* Made the is_loopback(), is_unspecified() and is_multicast() functions
  consistently available across the ip::address, ip::address_v4 and
  ip::address_v6 classes. Refs #3939.

* Added new non_blocking() functions for managing the non-blocking
  behaviour of a socket or descriptor. The io_control() commands named
  non_blocking_io are now deprecated in favour of these new functions.

* Added new native_non_blocking() functions for managing the
  non-blocking mode of the underlying socket or descriptor. These
  functions are intended to allow the encapsulation of arbitrary
  non-blocking system calls as asynchronous operations, in a way that is
  transparent to the user of the socket object. The functions have no
  effect on the behaviour of the synchronous operations of the socket or
  descriptor. Refs #3307.

* Added the io_control() member function for socket acceptors.
  Refs #3297.

* For consistency with the C++0x standard library, deprecated the
  native_type typedefs in favour of native_handle_type, and the native()
  member functions in favour of native_handle().

* Added a release() member function to posix descriptors. This function
  releases ownership of the underlying native descriptor to the caller.
  Refs #3900.

* Added support for sequenced packet sockets (SOCK_SEQPACKET).

* Added a new io_service::stopped() function that can be used to
  determine whether the io_service has stopped (i.e. a reset() call is
  needed prior to any further calls to run(), run_one(), poll() or
  poll_one()).

* Reduced the copying of handler function objects.

* Added support for C++0x move construction to further reduce copying of
  handler objects. Move support is enabled when compiling in -std=c++0x
  mode on g++ 4.5 or higher, or when using MSVC10.

* Removed the dependency on OS-provided macros for the well-known IPv4
  and IPv6 addresses. This should eliminate the annoying "missing braces
  around initializer" warnings. Refs #3741.

* Reduced the size of ip::basic_endpoint<> objects (such as
  ip::tcp::endpoint and ip::udp::endpoint).

* Changed the reactor backends to assume that any descriptors or sockets
  added using assign() may have been dup()-ed, and so require explicit
  deregistration from the reactor. Refs #4971.

* Changed the SSL error category to return error strings from the
  OpenSSL library.

* Changed the separate compilation support such that, to use Asio's SSL
  capabilities, you should also include 'asio/ssl/impl/src.hpp in one
  source file in your program.

* Removed the deprecated member functions named io_service(). The
  get_io_service() member functions should be used instead.

* Removed the deprecated typedefs resolver_query and resolver_iterator
  from the ip::tcp, ip::udp and ip::icmp classes.

* Fixed a compile error on some versions of g++ due to anonymous enums.
  Refs #4883.

* Added an explicit cast to the FIONBIO constant to int to suppress a
  compiler warning on some platforms. Refs #5128.

* Fixed warnings reported by g++'s -Wshadow compiler option. Refs #3905.


[SVN r69194]
2011-02-23 01:04:16 +00:00
Christopher Kohlhoff
b1dced94c8 Update copyright notice.
[SVN r68086]
2011-01-13 08:14:05 +00:00
Christopher Kohlhoff
986c2b8e9a Make unit tests build faster.
[SVN r65998]
2010-10-16 04:30:12 +00:00
Christopher Kohlhoff
0f5629d445 Reworked implementation MkII
[SVN r62499]
2010-06-07 00:00:45 +00:00
Christopher Kohlhoff
20a822c591 Update copyright notices.
[SVN r58623]
2010-01-02 01:24:52 +00:00
Christopher Kohlhoff
e5a0230dbc Need to specify socket lib to link correctly on QNX. Fixes #2504.
[SVN r50943]
2009-02-01 11:37:18 +00:00
Christopher Kohlhoff
4696ee9033 Add class to allow use of arbitrary Windows overlapped I/O operations.
[SVN r48495]
2008-08-31 11:38:52 +00:00
Christopher Kohlhoff
bb6bfd4b5a Change the CompletionCondition concept so that:
- It is now evaluated before the first call to the underlying
  *_some() operation, as well as after every operation.
- The return value is a number of bytes, which indicates the maximum
  length to be transferred on the subsequent *_some() operation. If
  the return value is 0 then the composed operation completes.

Add missing unit tests for read_at and write_at.


[SVN r48418]
2008-08-28 12:11:47 +00:00
Christopher Kohlhoff
10e8419c7e Some linux configurations do not automatically define _XOPEN_SOURCE.
[SVN r46876]
2008-06-30 00:24:44 +00:00
Christopher Kohlhoff
1539f2c8a1 Add an iterator for bytewise traversal of a buffer sequence.
[SVN r46415]
2008-06-16 00:41:29 +00:00
Christopher Kohlhoff
fa82af9e16 Add random-access handles for use on Windows.
[SVN r46319]
2008-06-11 11:17:53 +00:00
Christopher Kohlhoff
ee449aa163 Add new wrapper classes for stream-oriented handles on Windows.
[SVN r44676]
2008-04-21 05:32:34 +00:00
Christopher Kohlhoff
1ef42e04c6 Add new wrapper classes for stream-oriented file descriptors on POSIX platforms.
[SVN r44675]
2008-04-21 05:16:15 +00:00
Christopher Kohlhoff
f784e54ced Add support for UNIX domain sockets.
[SVN r44674]
2008-04-21 04:43:05 +00:00
Christopher Kohlhoff
02e47999fa Update copyright notices.
[SVN r43473]
2008-03-03 14:13:01 +00:00
Christopher Kohlhoff
ff29c1bcfb Only define _XOPEN_SOURCE_EXTENDED when building with gcc on HP-UX.
[SVN r43302]
2008-02-18 13:33:23 +00:00
Christopher Kohlhoff
86dc84f36d Need to define _XOPEN_SOURCE_EXTENDED when compiling for HP-UX.
[SVN r43221]
2008-02-11 13:59:44 +00:00
Christopher Kohlhoff
4010cfe9de Add define to disable /dev/poll support.
[SVN r40109]
2007-10-17 08:20:30 +00:00
Christopher Kohlhoff
36edaaf006 Try changing the default target to Windows XP rather than Windows 2000 to see
effect on borland-5.9.2.


[SVN r39865]
2007-10-09 21:59:38 +00:00
Christopher Kohlhoff
7825a45960 Add missing "lib ipv6 ;" that's needed for HP-UX.
[SVN r39517]
2007-09-25 01:56:46 +00:00
Christopher Kohlhoff
0987067acc Add extra library 'ipv6' needed on HP-UX.
[SVN r39509]
2007-09-24 13:32:47 +00:00
Christopher Kohlhoff
9f53a075ff Define _WIN32_WINNT to suppress warnings. Add define necessary
for building with cygwin.


[SVN r39100]
2007-09-01 07:32:28 +00:00
Christopher Kohlhoff
cc427bfc38 Need to specify Windows socket libraries with cw toolset.
[SVN r37045]
2007-02-23 02:28:24 +00:00