2
0
mirror of https://github.com/boostorg/asio.git synced 2026-01-27 18:42:07 +00:00
Commit Graph

15 Commits

Author SHA1 Message Date
Christopher Kohlhoff
68a7cd26a6 Merge asio from trunk.
------------------------------------------------------------------------
r85735 | chris_kohlhoff | 2013-09-18 07:31:55 +1000 (Wed, 18 Sep 2013) | 1 line

Remove dependency on Boost.Preprocessor library.
------------------------------------------------------------------------
r85736 | chris_kohlhoff | 2013-09-18 07:32:48 +1000 (Wed, 18 Sep 2013) | 1 line

Fix error in async_receive_from example.
------------------------------------------------------------------------
r85737 | chris_kohlhoff | 2013-09-18 07:33:39 +1000 (Wed, 18 Sep 2013) | 1 line

Remove unused variable assignment.
------------------------------------------------------------------------
r85738 | chris_kohlhoff | 2013-09-18 07:35:43 +1000 (Wed, 18 Sep 2013) | 3 lines

Fix a regression where, on some platforms, errors from async_connect are not
correctly propagated through to the completion handler.

------------------------------------------------------------------------
r85739 | chris_kohlhoff | 2013-09-18 07:36:54 +1000 (Wed, 18 Sep 2013) | 1 line

Remove unused parameters and member variables.
------------------------------------------------------------------------
r85740 | chris_kohlhoff | 2013-09-18 07:38:41 +1000 (Wed, 18 Sep 2013) | 1 line

Fix nfds argument to select.
------------------------------------------------------------------------
r85741 | chris_kohlhoff | 2013-09-18 07:39:38 +1000 (Wed, 18 Sep 2013) | 1 line

Fix a regression on Windows where multiple threads are running an io_service.
------------------------------------------------------------------------
r85742 | chris_kohlhoff | 2013-09-18 07:40:19 +1000 (Wed, 18 Sep 2013) | 1 line

Fix typo in serial ports overview.
------------------------------------------------------------------------
r85743 | chris_kohlhoff | 2013-09-18 07:41:04 +1000 (Wed, 18 Sep 2013) | 1 line

Ensure ssl::io_op::want_ member is initialised.
------------------------------------------------------------------------
r85744 | chris_kohlhoff | 2013-09-18 07:42:08 +1000 (Wed, 18 Sep 2013) | 1 line

Fix a bug in handler tracking, where it was not correctly printing out some handler IDs.
------------------------------------------------------------------------
r85745 | chris_kohlhoff | 2013-09-18 07:42:48 +1000 (Wed, 18 Sep 2013) | 1 line

Fix comparison used to test for a successful synchronous accept.
------------------------------------------------------------------------
r85746 | chris_kohlhoff | 2013-09-18 07:43:29 +1000 (Wed, 18 Sep 2013) | 3 lines

Ensure signal number is correctly passed to the completion handler when
starting an async_wait on a signal that is already raised.

------------------------------------------------------------------------
r85747 | chris_kohlhoff | 2013-09-18 07:45:43 +1000 (Wed, 18 Sep 2013) | 1 line

Suppress g++ 4.8+ warning about unused typedefs.
------------------------------------------------------------------------
r85748 | chris_kohlhoff | 2013-09-18 07:48:54 +1000 (Wed, 18 Sep 2013) | 1 line

Fix link to refer to native_handle() rather than the deprecated native() function.
------------------------------------------------------------------------
r85749 | chris_kohlhoff | 2013-09-18 07:51:28 +1000 (Wed, 18 Sep 2013) | 3 lines

Enable the move optimisation (and otherwise eliminate a copy) for handlers
using the default invocation hook.

------------------------------------------------------------------------
r85750 | chris_kohlhoff | 2013-09-18 07:52:27 +1000 (Wed, 18 Sep 2013) | 2 lines

Clarify that programs must not issue overlapping async_write_at operations.

------------------------------------------------------------------------
r85751 | chris_kohlhoff | 2013-09-18 07:53:03 +1000 (Wed, 18 Sep 2013) | 1 line

Fix error in comment.
------------------------------------------------------------------------
r85752 | chris_kohlhoff | 2013-09-18 07:53:45 +1000 (Wed, 18 Sep 2013) | 1 line

Remove spurious whitespace.
------------------------------------------------------------------------
r85753 | chris_kohlhoff | 2013-09-18 08:00:53 +1000 (Wed, 18 Sep 2013) | 2 lines

Clean up some internal forward declarations.

------------------------------------------------------------------------
r85754 | chris_kohlhoff | 2013-09-18 08:01:26 +1000 (Wed, 18 Sep 2013) | 1 line

Add missing move cast.
------------------------------------------------------------------------
r85755 | chris_kohlhoff | 2013-09-18 08:03:29 +1000 (Wed, 18 Sep 2013) | 3 lines

Fix another socket descriptor comparison that doesn't work correctly if
the descriptor type is unsigned.

------------------------------------------------------------------------
r85756 | chris_kohlhoff | 2013-09-18 08:04:10 +1000 (Wed, 18 Sep 2013) | 3 lines

Fix documentation error where an asynchronous function was described as
having synchronous behaviour.

------------------------------------------------------------------------
r85757 | chris_kohlhoff | 2013-09-18 08:04:55 +1000 (Wed, 18 Sep 2013) | 1 line

Add missing forward declarations needed for Windows.
------------------------------------------------------------------------
r85758 | chris_kohlhoff | 2013-09-18 08:05:38 +1000 (Wed, 18 Sep 2013) | 1 line

Remove use of std::min.
------------------------------------------------------------------------
r85759 | chris_kohlhoff | 2013-09-18 08:06:25 +1000 (Wed, 18 Sep 2013) | 3 lines

Inore ERROR_MORE_DATA as a non-fatal error when returned by
GetOverlappedResult for a synchronous read.

------------------------------------------------------------------------
r85760 | chris_kohlhoff | 2013-09-18 08:08:07 +1000 (Wed, 18 Sep 2013) | 2 lines

Enable certain C++11 standard library facilities for recent versions of Microsoft Visual Studio.

------------------------------------------------------------------------
r85761 | chris_kohlhoff | 2013-09-18 08:08:43 +1000 (Wed, 18 Sep 2013) | 4 lines

Visual C++ language extensions use generic as a keyword. Add a
workaround that renames the namespace to cpp_generic when those
language extensions are in effect.

------------------------------------------------------------------------
r85762 | chris_kohlhoff | 2013-09-18 08:12:07 +1000 (Wed, 18 Sep 2013) | 2 lines

Some async operations that missed getting the async_result treatment.

------------------------------------------------------------------------
r85763 | chris_kohlhoff | 2013-09-18 08:14:14 +1000 (Wed, 18 Sep 2013) | 2 lines

Eliminate some unnecessary handler copies.

------------------------------------------------------------------------
r85764 | chris_kohlhoff | 2013-09-18 08:24:19 +1000 (Wed, 18 Sep 2013) | 26 lines

Initial port to Windows Runtime.

This change adds limited support for using Asio with the Windows
Runtime. It requires that the language extensions be enabled. Due to the
restricted facilities exposed by the Windows Runtime API, the port comes
with the following caveats:

* The core facilities such as the io_service, strand, buffers, composed
  operations, timers, etc., should all work as normal.

* For sockets, only client-side TCP is supported.

* Explicit binding of a client-side TCP socket is not supported.

* The cancel() function is not supported for sockets. Asynchronous
  operations may only be cancelled by closing the socket.

* Operations that use null_buffers are not supported.

* Only tcp::no_delay and socket_base::keep_alive options are supported.

* Resolvers do not support service names, only numbers. I.e. you must
  use 80 rather than http.

* Most resolver query flags have no effect.

------------------------------------------------------------------------
r85765 | chris_kohlhoff | 2013-09-18 08:32:13 +1000 (Wed, 18 Sep 2013) | 1 line

Regenerate documentation.
------------------------------------------------------------------------
r85766 | chris_kohlhoff | 2013-09-18 08:38:04 +1000 (Wed, 18 Sep 2013) | 2 lines

Enable move support for Microsoft Visual C++ 2012.

------------------------------------------------------------------------
r85767 | chris_kohlhoff | 2013-09-18 08:42:50 +1000 (Wed, 18 Sep 2013) | 2 lines

Add use_future support for Microsoft Visual C++.

------------------------------------------------------------------------
r85768 | chris_kohlhoff | 2013-09-18 08:53:17 +1000 (Wed, 18 Sep 2013) | 2 lines

Fix prefix on extern "C" function name.

------------------------------------------------------------------------
r85781 | chris_kohlhoff | 2013-09-19 08:43:01 +1000 (Thu, 19 Sep 2013) | 1 line

Implement end-of-file condition for WinRT stream sockets.
------------------------------------------------------------------------
r85798 | chris_kohlhoff | 2013-09-20 22:00:44 +1000 (Fri, 20 Sep 2013) | 2 lines

Update buffered stream operations to adhere to current handler patterns.

------------------------------------------------------------------------
r85799 | chris_kohlhoff | 2013-09-20 22:02:33 +1000 (Fri, 20 Sep 2013) | 1 line

MinGW fix.
------------------------------------------------------------------------
r85800 | chris_kohlhoff | 2013-09-20 22:04:00 +1000 (Fri, 20 Sep 2013) | 1 line

Change unit tests so that they don't depend on Boost.Thread.
------------------------------------------------------------------------
r85801 | chris_kohlhoff | 2013-09-20 22:10:45 +1000 (Fri, 20 Sep 2013) | 1 line

Regenerate documentation.
------------------------------------------------------------------------
r85823 | danieljames | 2013-09-22 20:32:36 +1000 (Sun, 22 Sep 2013) | 1 line

Fix copying C++11 allocation examples
------------------------------------------------------------------------


[SVN r85838]
2013-09-22 22:13:33 +00:00
Christopher Kohlhoff
603397befb Merge from trunk.
------------------------------------------------------------------------
r84301 | chris_kohlhoff | 2013-05-17 07:34:54 +1000 (Fri, 17 May 2013) | 2 lines

Enable handler type requirements static_assert on clang.

------------------------------------------------------------------------
r84308 | chris_kohlhoff | 2013-05-17 09:26:04 +1000 (Fri, 17 May 2013) | 3 lines

Add new traits classes, handler_type and async_result, that allow
the customisation of the return type of an initiating function.

------------------------------------------------------------------------
r84311 | chris_kohlhoff | 2013-05-17 11:38:47 +1000 (Fri, 17 May 2013) | 81 lines

Add the asio::spawn() function, a high-level wrapper for running
stackful coroutines. It is based on the Boost.Coroutine library.

Here is an example of its use:

  asio::spawn(my_strand, do_echo);

  // ...

  void do_echo(asio::yield_context yield)
  {
    try
    {
      char data[128];
      for (;;)
      {
        std::size_t length =
          my_socket.async_read_some(
            asio::buffer(data), yield);

        asio::async_write(my_socket,
            asio::buffer(data, length), yield);
      }
    }
    catch (std::exception& e)
    {
      // ...
    }
  }

The first argument to asio::spawn() may be a strand, io_service or
completion handler. This argument determines the context in which the
coroutine is permitted to execute. For example, a server's per-client
object may consist of multiple coroutines; they should all run on the
same strand so that no explicit synchronisation is required.

The second argument is a function object with signature (**):

  void coroutine(asio::yield_context yield);

that specifies the code to be run as part of the coroutine. The
parameter yield may be passed to an asynchronous operation in place of
the completion handler, as in:

  std::size_t length =
    my_socket.async_read_some(
      asio::buffer(data), yield);

This starts the asynchronous operation and suspends the coroutine. The
coroutine will be resumed automatically when the asynchronous operation
completes.

Where a completion handler signature has the form:

  void handler(error_code ec, result_type result);

the initiating function returns the result_type. In the async_read_some
example above, this is std::size_t. If the asynchronous operation fails,
the error_code is converted into a system_error exception and thrown.

Where a completion handler signature has the form:

  void handler(error_code ec);

the initiating function returns void. As above, an error is passed back
to the coroutine as a system_error exception.

To collect the error_code from an operation, rather than have it throw
an exception, associate the output variable with the yield_context as
follows:

  error_code ec;
  std::size_t length =
    my_socket.async_read_some(
      asio::buffer(data), yield[ec]);

**Note: if asio::spawn() is used with a custom completion handler of
type Handler, the function object signature is actually:
  
  void coroutine(asio::basic_yield_context<Handler> yield);

------------------------------------------------------------------------
r84312 | chris_kohlhoff | 2013-05-17 12:25:10 +1000 (Fri, 17 May 2013) | 4 lines

Move existing examples into a C++03-specific directory, and add a new
directory for C++11-specific examples. A limited subset of the C++03
examples have been converted to their C++11 equivalents.

------------------------------------------------------------------------
r84313 | chris_kohlhoff | 2013-05-17 12:35:08 +1000 (Fri, 17 May 2013) | 26 lines

Add the asio::use_future special value, which adds first-class support
for returning a C++11 std::future from an asynchronous operation's
initiating function.

To use asio::use_future, pass it to an asynchronous operation instead of
a normal completion handler. For example:

  std::future<std::size_t> length =
    my_socket.async_read_some(my_buffer, asio::use_future);

Where a completion handler signature has the form:

  void handler(error_code ec, result_type result);

the initiating function returns a std::future templated on result_type.
In the above example, this is std::size_t. If the asynchronous operation
fails, the error_code is converted into a system_error exception and
passed back to the caller through the future.

Where a completion handler signature has the form:

  void handler(error_code ec);

the initiating function returns std::future<void>. As above, an error
is passed back in the future as a system_error exception.

------------------------------------------------------------------------
r84314 | chris_kohlhoff | 2013-05-17 13:07:51 +1000 (Fri, 17 May 2013) | 27 lines

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.

------------------------------------------------------------------------
r84315 | chris_kohlhoff | 2013-05-17 20:06:50 +1000 (Fri, 17 May 2013) | 3 lines

Partially decouple Asio from other boost components via an extra level
of indirection.

------------------------------------------------------------------------
r84316 | chris_kohlhoff | 2013-05-17 20:15:21 +1000 (Fri, 17 May 2013) | 2 lines

Minor cleanup.

------------------------------------------------------------------------
r84319 | chris_kohlhoff | 2013-05-17 20:52:08 +1000 (Fri, 17 May 2013) | 9 lines

Support handshake with re-use of data already read from the wire.

Add new overloads of the SSL stream's handshake() and async_handshake()
functions, that accepts a ConstBufferSequence to be used as initial
input to the ssl engine for the handshake procedure.

Thanks go to Nick Jones <nick dot fa dot jones at gmail dot com>, on
whose work this commit is partially based.

------------------------------------------------------------------------
r84320 | chris_kohlhoff | 2013-05-17 20:57:02 +1000 (Fri, 17 May 2013) | 6 lines

Support for creation of TLSv1.1 and TLSv1.2 contexts.

Thanks go to Alvin Cheung <alvin dot cheung at alumni dot ust dot hk>
and Nick Jones <nick dot fa dot jones at gmail dot com>, on whose work
this is based.

------------------------------------------------------------------------
r84322 | chris_kohlhoff | 2013-05-17 21:00:49 +1000 (Fri, 17 May 2013) | 5 lines

Add set_verify_depth function to SSL context and stream.

Thanks go to Nick Jones <nick dot fa dot jones at gmail dot com>, on
whose work this commit is based.

------------------------------------------------------------------------
r84325 | chris_kohlhoff | 2013-05-17 21:04:11 +1000 (Fri, 17 May 2013) | 9 lines

Allow loading of SSL certificate and key data from memory buffers.

Added new buffer-based interfaces:
add_certificate_authority, use_certificate, use_certificate_chain,
use_private_key, use_rsa_private_key, use_tmp_dh.

Thanks go to Nick Jones <nick dot fa dot jones at gmail dot com>, on
whose work this commit is based.

------------------------------------------------------------------------
r84345 | chris_kohlhoff | 2013-05-18 21:24:59 +1000 (Sat, 18 May 2013) | 2 lines

Update copyright notices.

------------------------------------------------------------------------
r84346 | chris_kohlhoff | 2013-05-18 21:54:59 +1000 (Sat, 18 May 2013) | 3 lines

Remove the stackless coroutine class and macros from the HTTP server 4
example, and instead make them a part of Asio's documented interface.

------------------------------------------------------------------------
r84347 | chris_kohlhoff | 2013-05-18 22:01:59 +1000 (Sat, 18 May 2013) | 4 lines

Fix basic_waitable_timer's underlying implementation so that it can
handle any time_point value without overflowing the intermediate
duration objects.

------------------------------------------------------------------------
r84348 | chris_kohlhoff | 2013-05-18 22:07:00 +1000 (Sat, 18 May 2013) | 3 lines

Fix a problem with lost thread wakeups that can occur when making
concurrent calls to run() and poll() on the same io_service object.

------------------------------------------------------------------------
r84349 | chris_kohlhoff | 2013-05-18 22:13:17 +1000 (Sat, 18 May 2013) | 3 lines

Fix implementation of asynchronous connect operation so that it can cope
with spurious readiness notifications from the reactor.

------------------------------------------------------------------------
r84361 | chris_kohlhoff | 2013-05-19 07:56:31 +1000 (Sun, 19 May 2013) | 1 line

Remove some trailing spaces and fix another copyright notice.

------------------------------------------------------------------------
r84363 | chris_kohlhoff | 2013-05-19 14:55:11 +1000 (Sun, 19 May 2013) | 53 lines

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 r84388]
2013-05-20 12:32:20 +00:00
Christopher Kohlhoff
bb38d425fb Merge from trunk:
* Chrono support.

* Added object_handle support.

* Need to enable the basic_handle class when object_handle is supported.

* Update copyright notices.

* Fix MSVC "performance warning".

* Fix for NetBSD. Fixes #6098.

* Fix regression in buffered_write_stream. Fixes #6310.

* Fix deadlock on Mac OS X. Fixes #6275.

* On linux, connect can return EAGAIN in certain circumstances. Remap to another
  error so that it doesn't look like a non-blocking operation. Fixes #6048.

* Fix non-paged pool "leak" on Windows when io_service is repeatedly run without anything to do. Fixes #6321.

* Disable object_handle on Windows CE.

* Add extra include required for OVERLAPPED struct.

* Fix doxygen comments.

* Update documentation.

* Add missing class.

* Update copyright year.


[SVN r76516]
2012-01-15 13:46:25 +00:00
Christopher Kohlhoff
b91e7a6f65 Merge asio from trunk.
[SVN r72428]
2011-06-05 23:21:43 +00:00
Christopher Kohlhoff
28ab37a23e Merge from trunk:
* Update copyright notice.

* Version bump.

* Fix out-of-bounds address_v4::broadcast() return value on 64-bit systems.

* Use correct interrupt method when timerfd is not available. Fixes #5045


[SVN r68200]
2011-01-17 04:28:16 +00:00
Christopher Kohlhoff
0f5629d445 Reworked implementation MkII
[SVN r62499]
2010-06-07 00:00:45 +00:00
Christopher Kohlhoff
235e35039d Include specific headers in unit tests rather than the convenience header asio.hpp.
[SVN r58626]
2010-01-02 07:18:09 +00:00
Christopher Kohlhoff
20a822c591 Update copyright notices.
[SVN r58623]
2010-01-02 01:24:52 +00:00
Christopher Kohlhoff
8768d9dff1 Fix or suppress MSVC level 4 warnings. Fixes #1703.
[SVN r44727]
2008-04-22 23:46:15 +00:00
Christopher Kohlhoff
f99a3cb814 Update copyright notices.
[SVN r43472]
2008-03-03 14:05:35 +00:00
Christopher Kohlhoff
2b4748aaaa Update copyright strings to include 2007.
[SVN r36581]
2007-01-04 05:53:07 +00:00
Christopher Kohlhoff
7c9fe2a5ac Ensure that what gets thrown is the system_error exception.
[SVN r35947]
2006-11-09 11:21:43 +00:00
Christopher Kohlhoff
c7f491b73e Fix comment headers to match file names.
[SVN r35941]
2006-11-09 03:02:19 +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