Commit Graph

45 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
d547df309f Add network_v[46].hpp headers to top-level convenience header. 2019-02-28 20:15:26 +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
b572bfbc21 Remove deprecated handler_type and single-argument async_result. 2019-02-17 20:00:05 -10: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
886839cf55 Update copyright notices. 2018-03-04 21:59:30 +11:00
Christopher Kohlhoff
8a8157c36d Add waitable timer headers to convenience header. 2017-12-02 09:16:54 +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
Christopher Kohlhoff
41bf42b8da Update copyright notices. 2015-03-20 00:14:19 +11:00
Christopher Kohlhoff
28f690f504 Update copyright notices. 2014-05-03 09:25:39 +10:00
Christopher Kohlhoff
e290a34cd3 Reverted asio changed made under [85904], [85952], [86050] and [86105]. Will reconsider after 1.55 is released.
[SVN r86151]
2013-10-03 22:59:24 +00:00
Stephen Kelly
93b2b4dc46 Remove obsolete MSVC check from pragma guard
git grep -h -B1 "^#\s*pragma once" | grep -v pragma | sort | uniq

is now clean.

[SVN r85952]
2013-09-26 13:02:51 +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
1bba399354 Add a new handler hook called asio_handler_is_continuation.
Asynchronous operations may represent a continuation of the asynchronous
control flow associated with the current handler. Asio's implementation
can use this knowledge to optimise scheduling of the handler.

The asio_handler_is_continuation hook returns true to indicate whether a
completion handler represents a continuation of the current call
context. The default implementation of the hook returns false, and
applications may customise the hook when necessary. The hook has already
been customised within Asio to return true for the following cases:

- Handlers returned by strand.wrap(), when the corresponding
  asynchronous operation is being initiated from within the strand.

- The internal handlers used to implement the asio::spawn() function's
  stackful coroutines.

- When an intermediate handler of a composed operation (e.g.
  asio::async_read(), asio::async_write(), asio::async_connect(),
  ssl::stream<>, etc.) starts a new asynchronous operation due to the
  composed operation not being complete.

To support this optimisation, a new running_in_this_thread() member
function has been added to the io_service::strand class. This function
returns true when called from within a strand.


[SVN r84314]
2013-05-17 03:07:51 +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
20a822c591 Update copyright notices.
[SVN r58623]
2010-01-02 01:24:52 +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
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
7e062f298d Add support for serial ports.
[SVN r46272]
2008-06-09 12:54:55 +00:00
Christopher Kohlhoff
23c4f7061d Add raw socket support.
[SVN r44849]
2008-04-28 13:36:18 +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
f99a3cb814 Update copyright notices.
[SVN r43472]
2008-03-03 14:05:35 +00:00
Beman Dawes
7ba40bdcb8 // Add or correct comment identifying Boost library this header is associated with.
[SVN r41173]
2007-11-17 20:13:16 +00:00
Christopher Kohlhoff
288b994d9b Add header file containing Boost.Asio version number.
[SVN r37628]
2007-05-08 12:20:38 +00:00
Christopher Kohlhoff
5607a01c21 Add ip::unicast::hops and ip::v6_only socket options.
[SVN r36595]
2007-01-06 09:10:54 +00:00
Christopher Kohlhoff
2b4748aaaa Update copyright strings to include 2007.
[SVN r36581]
2007-01-04 05:53:07 +00:00
Christopher Kohlhoff
852668d1da Change error handling to match TR2 proposal.
[SVN r35911]
2006-11-08 05:32:17 +00:00
Christopher Kohlhoff
da2ef49a00 Add max_size() function to basic_streambuf.
Make basic_io_object constructor protected.

Make a 0-length send or receive on a stream socket into a no-op.

Add cancel() function for cancelling asynchronous socket operations.
The Win32 implementation only works if all operations for the socket
have been issued from the same thread, otherwise it fails with
asio::error::not_supported.

Add workaround for an apparent Windows bug where using getpeername on
a socket accepted using AcceptEx will sometimes return an endpoint
that is all zeroes.

Make a strand last as long as it has any handlers to dispatch. Make
strand a nested class of io_service.

Add io_service() function to io_service::work to return a reference to
the io_service object on which the work is being performed. Renamed
io_service::service::owner() to io_service::service::io_service().

Unset linger object when socket objects are destroyed.

Rename asio_handler_dispatch to asio_handler_invoke.

Rename basic_socketbuf to basic_socket_streambuf.

Update ip::address_v4 and ip::address_v6 classes to match TR2
proposal.

Add run_one(), poll() and poll_one() functions to the io_service.

Remove need to #define FD_SETSIZE on Win32.

Add detection of incorrect inclusion of WinSock.h.

Fix some SSL bugs. Add ability to customise the SSL password callback
function.

Set the reuse_address option by default on acceptors.

The macros FIONREAD and FIONBIO are not integer constants on all
platforms, and so cannot be used as template arguments. Make the
corresponding I/O control commands into proper classes, not templates.

Fixes to better support *BSD platforms.

Add support for buffer debugging, if the standard library supports
iterator debugging (as MSVC8's standard lib does).

Ensure the IOCP queue is drained correctly at shutdown.

Move basic_resolver and resolver service into the ip namespace.

Fix some issues found by the inspect tool.


[SVN r35833]
2006-11-04 07:14:10 +00:00
Christopher Kohlhoff
7027bf39d5 Change strand implementation so that dispatch will execute a handler
immediately if called from within the strand.

Add hook function for customising handler dispatch.

Need to use reinterpret_cast when testing for enable_connection_aborted
socket option, to allow non-int socket options to compile correctly.


[SVN r34464]
2006-07-05 05:48:10 +00:00
Christopher Kohlhoff
da0cf5f68a Initial asio checkin.
[SVN r34306]
2006-06-14 22:26:36 +00:00