|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r72404 - in trunk: boost/asio boost/asio/detail libs/asio/doc libs/asio/doc/overview libs/asio/example/timers
From: chris_at_[hidden]
Date: 2011-06-05 09:29:43
Author: chris_kohlhoff
Date: 2011-06-05 09:29:41 EDT (Sun, 05 Jun 2011)
New Revision: 72404
URL: http://svn.boost.org/trac/boost/changeset/72404
Log:
* Add documentation for new features.
* Duration type should be signed in tick_count_timer example.
* Regenerate documentation.
* Make definition of BOOST_ASIO_MOVE_ARG and BOOST_ASIO_MOVE_CAST separate to
the definition of BOOST_ASIO_HAS_MOVE, to allow the latter to be user-defined.
Added:
trunk/libs/asio/doc/overview/cpp2011.qbk (contents, props changed)
trunk/libs/asio/doc/overview/handler_tracking.qbk (contents, props changed)
trunk/libs/asio/doc/overview/signals.qbk (contents, props changed)
Text files modified:
trunk/boost/asio/buffer.hpp | 18 +++++++++++++
trunk/boost/asio/detail/config.hpp | 18 ++++++++----
trunk/libs/asio/doc/overview/iostreams.qbk | 26 +++++++++++++++++++
trunk/libs/asio/doc/overview/posix.qbk | 39 ++++++++++++++++++++++++++++
trunk/libs/asio/doc/overview/protocols.qbk | 34 +++++++++++++++++++++++-
trunk/libs/asio/doc/overview/reactor.qbk | 5 ++-
trunk/libs/asio/doc/overview/ssl.qbk | 54 ++++++++++++++++++++++++++++++++++++++++
trunk/libs/asio/doc/reference.dox | 3 +
trunk/libs/asio/doc/reference.qbk | 29 ++++++++++++++++++--
trunk/libs/asio/doc/tutorial.qbk | 16 +++++++----
trunk/libs/asio/example/timers/tick_count_timer.cpp | 15 ++++++++--
11 files changed, 232 insertions(+), 25 deletions(-)
Modified: trunk/boost/asio/buffer.hpp
==============================================================================
--- trunk/boost/asio/buffer.hpp (original)
+++ trunk/boost/asio/buffer.hpp 2011-06-05 09:29:41 EDT (Sun, 05 Jun 2011)
@@ -594,6 +594,24 @@
* The boost::asio::buffer_cast function permits violations of type safety, so
* uses of it in application code should be carefully considered.
*
+ * For convenience, the @ref buffer_size function also works on buffer
+ * sequences (that is, types meeting the ConstBufferSequence or
+ * MutableBufferSequence type requirements). In this case, the function returns
+ * the total size of all buffers in the sequence.
+ *
+ * @par Buffer Copying
+ *
+ * The @ref buffer_copy function may be used to copy raw bytes between
+ * individual buffers and buffer sequences.
+ *
+ * In particular, when used with the @ref buffer_size, the @ref buffer_copy
+ * function can be used to linearise a sequence of buffers. For example:
+ *
+ * @code vector<const_buffer> buffers = ...;
+ *
+ * vector<unsigned char> data(boost::asio::buffer_size(buffers));
+ * boost::asio::buffer_copy(boost::asio::buffer(data), buffers); @endcode
+ *
* @par Buffer Invalidation
*
* A buffer object does not have any ownership of the memory it refers to. It
Modified: trunk/boost/asio/detail/config.hpp
==============================================================================
--- trunk/boost/asio/detail/config.hpp (original)
+++ trunk/boost/asio/detail/config.hpp 2011-06-05 09:29:41 EDT (Sun, 05 Jun 2011)
@@ -52,17 +52,23 @@
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
# define BOOST_ASIO_HAS_MOVE
-# define BOOST_ASIO_MOVE_ARG(type) type&&
-# define BOOST_ASIO_MOVE_CAST(type) static_cast<type&&>
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
# endif // defined(__GNUC__)
#endif // !defined(BOOST_ASIO_DISABLE_MOVE)
-// If BOOST_ASIO_MOVE_CAST isn't defined yet use a C++03 compatible version.
-// Note that older g++ and MSVC versions don't like it when you pass a
-// non-member function through a const reference, so for most compilers we'll
-// play it safe and stick with the old approach of passing the handler by
+// If BOOST_ASIO_MOVE_CAST isn't defined, and move support is available, define
+// BOOST_ASIO_MOVE_ARG and BOOST_ASIO_MOVE_CAST to take advantage of rvalue
+// references and perfect forwarding.
+#if defined(BOOST_ASIO_HAS_MOVE) && !defined(BOOST_ASIO_MOVE_CAST)
+# define BOOST_ASIO_MOVE_ARG(type) type&&
+# define BOOST_ASIO_MOVE_CAST(type) static_cast<type&&>
+#endif // defined(BOOST_ASIO_HAS_MOVE) && !defined(BOOST_ASIO_MOVE_CAST)
+
+// If BOOST_ASIO_MOVE_CAST still isn't defined, default to a C++03-compatible
+// implementation. Note that older g++ and MSVC versions don't like it when you
+// pass a non-member function through a const reference, so for most compilers
+// we'll play it safe and stick with the old approach of passing the handler by
// value.
#if !defined(BOOST_ASIO_MOVE_CAST)
# if defined(__GNUC__)
Added: trunk/libs/asio/doc/overview/cpp2011.qbk
==============================================================================
--- (empty file)
+++ trunk/libs/asio/doc/overview/cpp2011.qbk 2011-06-05 09:29:41 EDT (Sun, 05 Jun 2011)
@@ -0,0 +1,194 @@
+[/
+ / Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+ /
+ / Distributed under the Boost Software License, Version 1.0. (See accompanying
+ / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ /]
+
+[section:cpp2011 C++ 2011 Support]
+
+
+[link boost_asio.overview.cpp2011.move_objects Movable I/O Objects]
+
+[link boost_asio.overview.cpp2011.move_handlers Movable Handlers]
+
+[link boost_asio.overview.cpp2011.variadic Variadic Templates]
+
+[link boost_asio.overview.cpp2011.array Array Container]
+
+[link boost_asio.overview.cpp2011.atomic Atomics]
+
+[link boost_asio.overview.cpp2011.shared_ptr Shared Pointers]
+
+
+[section:move_objects Movable I/O Objects]
+
+When move support is available (via rvalue references), Boost.Asio allows move
+construction and assignment of sockets, serial ports, POSIX descriptors and
+Windows handles.
+
+Move support allows you to write code like:
+
+ tcp::socket make_socket(io_service& i)
+ {
+ tcp::socket s(i);
+ ...
+ std::move(s);
+ }
+
+or:
+
+ class connection : public enable_shared_from_this<connection>
+ {
+ private:
+ tcp::socket socket_;
+ ...
+ public:
+ connection(tcp::socket&& s) : socket_(std::move(s)) {}
+ ...
+ };
+
+ ...
+
+ class server
+ {
+ private:
+ tcp::acceptor acceptor_;
+ tcp::socket socket_;
+ ...
+ void handle_accept(error_code ec)
+ {
+ if (!ec)
+ std::make_shared<connection>(std::move(socket_))->go();
+ acceptor_.async_accept(socket_, ...);
+ }
+ ...
+ };
+
+as well as:
+
+ std::vector<tcp::socket> sockets;
+ sockets.push_back(tcp::socket(...));
+
+A word of warning: There is nothing stopping you from moving these objects
+while there are pending asynchronous operations, but it is unlikely to be a
+good idea to do so. In particular, composed operations like [link
+boost_asio.reference.async_read async_read()] store a reference to the stream object.
+Moving during the composed operation means that the composed operation may
+attempt to access a moved-from object.
+
+Move support is automatically enabled for [^g++] 4.5 and later, when the
+[^-std=c++0x] or [^-std=gnu++0x] compiler options are used. It may be disabled
+by defining `BOOST_ASIO_DISABLE_MOVE`, or explicitly enabled for other compilers by
+defining `BOOST_ASIO_HAS_MOVE`. Note that these macros also affect the availability
+of [link boost_asio.overview.cpp2011.move_handlers movable handlers].
+
+[endsect]
+
+[section:move_handlers Movable Handlers]
+
+As an optimisation, user-defined completion handlers may provide move
+constructors, and Boost.Asio's implementation will use a handler's move constructor
+in preference to its copy constructor. In certain circumstances, Boost.Asio may be
+able to eliminate all calls to a handler's copy constructor. However, handler
+types are still required to be copy constructible.
+
+When move support is enabled, asynchronous that are documented as follows:
+
+ template <typename Handler>
+ void async_XYZ(..., Handler handler);
+
+are actually declared as:
+
+ template <typename Handler>
+ void async_XYZ(..., Handler&& handler);
+
+The handler argument is perfectly forwarded and the move construction occurs
+within the body of `async_XYZ()`. This ensures that all other function
+arguments are evaluated prior to the move. This is critical when the other
+arguments to `async_XYZ()` are members of the handler. For example:
+
+ struct my_operation
+ {
+ shared_ptr<tcp::socket> socket;
+ shared_ptr<vector<char>> buffer;
+ ...
+ void operator(error_code ec, size_t length)
+ {
+ ...
+ socket->async_read_some(boost::asio::buffer(*buffer), std::move(*this));
+ ...
+ }
+ };
+
+Move support is automatically enabled for [^g++] 4.5 and later, when the
+[^-std=c++0x] or [^-std=gnu++0x] compiler options are used. It may be disabled
+by defining `BOOST_ASIO_DISABLE_MOVE`, or explicitly enabled for other compilers by
+defining `BOOST_ASIO_HAS_MOVE`. Note that these macros also affect the availability
+of [link boost_asio.overview.cpp2011.move_objects movable I/O objects].
+
+[endsect]
+
+[section:variadic Variadic Templates]
+
+When supported by a compiler, Boost.Asio can use variadic templates to implement the
+[link boost_asio.reference.basic_socket_streambuf.connect
+basic_socket_streambuf::connect()] and [link
+boost_asio.reference.basic_socket_iostream.connect basic_socket_iostream::connect()]
+functions.
+
+Support for variadic templates is automatically enabled for [^g++] 4.3 and
+later, when the [^-std=c++0x] or [^-std=gnu++0x] compiler options are used. It
+may be disabled by defining `BOOST_ASIO_DISABLE_VARIADIC_TEMPLATES`, or explicitly
+enabled for other compilers by defining `BOOST_ASIO_HAS_VARIADIC_TEMPLATES`.
+
+[endsect]
+
+[section:array Array Container]
+
+Where the standard library provides `std::array<>`, Boost.Asio:
+
+* Provides overloads for the [link boost_asio.reference.buffer buffer()] function.
+
+* Uses it in preference to `boost::array<>` for the
+ [link boost_asio.reference.ip__address_v4.bytes_type ip::address_v4::bytes_type] and
+ [link boost_asio.reference.ip__address_v6.bytes_type ip::address_v6::bytes_type]
+ types.
+
+* Uses it in preference to `boost::array<>` where a fixed size array type is
+ needed in the implementation.
+
+Support for `std::array<>` is automatically enabled for [^g++] 4.3 and later,
+when the [^-std=c++0x] or [^-std=gnu++0x] compiler options are used, as well as
+for Microsoft Visual C++ 10. It may be disabled by defining
+`BOOST_ASIO_DISABLE_STD_ARRAY`, or explicitly enabled for other compilers by
+defining `BOOST_ASIO_HAS_STD_ARRAY`.
+
+[endsect]
+
+[section:atomic Atomics]
+
+Boost.Asio's implementation can use `std::atomic<>` in preference to
+`boost::detail::atomic_count`.
+
+Support for the standard atomic integer template is automatically enabled for
+[^g++] 4.5 and later, when the [^-std=c++0x] or [^-std=gnu++0x] compiler
+options are used. It may be disabled by defining `BOOST_ASIO_DISABLE_STD_ATOMIC`, or
+explicitly enabled for other compilers by defining `BOOST_ASIO_HAS_STD_ATOMIC`.
+
+[endsect]
+
+[section:shared_ptr Shared Pointers]
+
+Boost.Asio's implementation can use `std::shared_ptr<>` and `std::weak_ptr<>` in
+preference to the Boost equivalents.
+
+Support for the standard smart pointers is automatically enabled for [^g++] 4.3
+and later, when the [^-std=c++0x] or [^-std=gnu++0x] compiler options are used,
+as well as for Microsoft Visual C++ 10. It may be disabled by defining
+`BOOST_ASIO_DISABLE_STD_SHARED_PTR`, or explicitly enabled for other compilers by
+defining `BOOST_ASIO_HAS_STD_SHARED_PTR`.
+
+[endsect]
+
+[endsect]
Added: trunk/libs/asio/doc/overview/handler_tracking.qbk
==============================================================================
--- (empty file)
+++ trunk/libs/asio/doc/overview/handler_tracking.qbk 2011-06-05 09:29:41 EDT (Sun, 05 Jun 2011)
@@ -0,0 +1,100 @@
+[/
+ / Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+ /
+ / Distributed under the Boost Software License, Version 1.0. (See accompanying
+ / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ /]
+
+[section:handler_tracking Handler Tracking]
+
+To aid in debugging asynchronous programs, Boost.Asio provides support for handler
+tracking. When enabled by defining `BOOST_ASIO_ENABLE_HANDLER_TRACKING`, Boost.Asio
+writes debugging output to the standard error stream. The output records
+asynchronous operations and the relationships between their handlers.
+
+This feature is useful when debugging and you need to know how your
+asynchronous operations are chained together, or what the pending asynchronous
+operations are. As an illustration, here is the output when you run the HTTP
+Server example, handle a single request, then shut down via Ctrl+C:
+
+ @asio|1298160085.070638|0*1|signal_set_at_0x7fff50528f40.async_wait
+ @asio|1298160085.070888|0*2|socket_at_0x7fff50528f60.async_accept
+ @asio|1298160085.070913|0|resolver_at_0x7fff50528e28.cancel
+ @asio|1298160118.075438|>2|ec=asio.system:0
+ @asio|1298160118.075472|2*3|socket_at_0xb39048.async_receive
+ @asio|1298160118.075507|2*4|socket_at_0x7fff50528f60.async_accept
+ @asio|1298160118.075527|<2|
+ @asio|1298160118.075540|>3|ec=asio.system:0,bytes_transferred=122
+ @asio|1298160118.075731|3*5|socket_at_0xb39048.async_send
+ @asio|1298160118.075778|<3|
+ @asio|1298160118.075793|>5|ec=asio.system:0,bytes_transferred=156
+ @asio|1298160118.075831|5|socket_at_0xb39048.close
+ @asio|1298160118.075855|<5|
+ @asio|1298160122.827317|>1|ec=asio.system:0,signal_number=2
+ @asio|1298160122.827333|1|socket_at_0x7fff50528f60.close
+ @asio|1298160122.827359|<1|
+ @asio|1298160122.827370|>4|ec=asio.system:125
+ @asio|1298160122.827378|<4|
+ @asio|1298160122.827394|0|signal_set_at_0x7fff50528f40.cancel
+
+Each line is of the form:
+
+ <tag>|<timestamp>|<action>|<description>
+
+The `<tag>` is always `@asio`, and is used to identify and extract the handler
+tracking messages from the program output.
+
+The `<timestamp>` is seconds and microseconds from 1 Jan 1970 UTC.
+
+The `<action>` takes one of the following forms:
+
+[variablelist
+ [
+ [>n]
+ [The program entered the handler number `n`. The `<description>` shows the
+ arguments to the handler.]
+ ]
+ [
+ [<n]
+ [The program left handler number `n`.]
+ ]
+ [
+ [!n]
+ [The program left handler number n due to an exception.]
+ ]
+ [
+ [~n]
+ [The handler number `n` was destroyed without having been invoked. This is
+ usually the case for any unfinished asynchronous operations when the
+ `io_service` is destroyed.]
+ ]
+ [
+ [n*m]
+ [The handler number `n` created a new asynchronous operation with completion
+ handler number `m`. The `<description>` shows what asynchronous operation
+ was started.]
+ ]
+ [
+ [n]
+ [The handler number n performed some other operation. The `<description>`
+ shows what function was called. Currently only `close()` and `cancel()`
+ operations are logged, as these may affect the state of pending
+ asynchronous operations.]
+ ]
+]
+
+Where the `<description>` shows a synchronous or asynchronous operation, the
+format is `<object-type>@<pointer>.<operation>`. For handler entry, it shows a
+comma-separated list of arguments and their values.
+
+As shown above, Each handler is assigned a numeric identifier. Where the
+handler tracking output shows a handler number of 0, it means that the action
+was performed outside of any handler.
+
+[heading Visual Representations]
+
+The handler tracking output may be post-processed using the included
+[^handlerviz.pl] tool to create a visual representation of the handlers
+(requires the GraphViz tool [^dot]).
+
+[endsect]
Modified: trunk/libs/asio/doc/overview/iostreams.qbk
==============================================================================
--- trunk/libs/asio/doc/overview/iostreams.qbk (original)
+++ trunk/libs/asio/doc/overview/iostreams.qbk 2011-06-05 09:29:41 EDT (Sun, 05 Jun 2011)
@@ -32,6 +32,32 @@
...
}
+Timeouts may be set by calling `expires_at()` or `expires_from_now()` to
+establish a deadline. Any socket operations that occur past the deadline will
+put the iostream into a "bad" state.
+
+For example, a simple client program like this:
+
+ ip::tcp::iostream stream;
+ stream.expires_from_now(boost::posix_time::seconds(60));
+ stream.connect("www.boost.org", "http");
+ stream << "GET /LICENSE_1_0.txt HTTP/1.0\r\n";
+ stream << "Host: www.boost.org\r\n";
+ stream << "Accept: */*\r\n";
+ stream << "Connection: close\r\n\r\n";
+ stream.flush();
+ std::cout << stream.rdbuf();
+
+will fail if all the socket operations combined take longer than 60 seconds.
+
+If an error does occur, the iostream's `error()` member function may be used to
+retrieve the error code from the most recent system call:
+
+ if (!stream)
+ {
+ std::cout << "Error: " << stream.error().message() << "\n";
+ }
+
[heading See Also]
[link boost_asio.reference.ip__tcp.iostream ip::tcp::iostream],
Modified: trunk/libs/asio/doc/overview/posix.qbk
==============================================================================
--- trunk/libs/asio/doc/overview/posix.qbk (original)
+++ trunk/libs/asio/doc/overview/posix.qbk 2011-06-05 09:29:41 EDT (Sun, 05 Jun 2011)
@@ -11,6 +11,8 @@
[link boost_asio.overview.posix.stream_descriptor Stream-Oriented File Descriptors]
+[link boost_asio.overview.posix.fork Fork]
+
[section:local UNIX Domain Sockets]
Boost.Asio provides basic support UNIX domain sockets (also known as local sockets).
@@ -103,4 +105,41 @@
[endsect]
+[section:fork Fork]
+
+Boost.Asio supports programs that utilise the `fork()` system call. Provided the
+program calls `io_service.notify_fork()` at the appropriate times, Boost.Asio will
+recreate any internal file descriptors (such as the "self-pipe trick"
+descriptor used for waking up a reactor). The notification is usually performed
+as follows:
+
+ io_service_.notify_fork(boost::asio::io_service::fork_prepare);
+ if (fork() == 0)
+ {
+ io_service_.notify_fork(boost::asio::io_service::fork_child);
+ ...
+ }
+ else
+ {
+ io_service_.notify_fork(boost::asio::io_service::fork_parent);
+ ...
+ }
+
+User-defined services can also be made fork-aware by overriding the
+`io_service::service::fork_service()` virtual function.
+
+Note that any file descriptors accessible via Boost.Asio's public API (e.g. the
+descriptors underlying `basic_socket<>`, `posix::stream_descriptor`, etc.) are
+not altered during a fork. It is the program's responsibility to manage these
+as required.
+
+[heading See Also]
+
+[link boost_asio.reference.io_service.notify_fork io_service::notify_fork()],
+[link boost_asio.reference.io_service.fork_event io_service::fork_event],
+[link boost_asio.reference.io_service__service.fork_service io_service::service::fork_service()],
+[link boost_asio.examples.fork Fork examples].
+
+[endsect]
+
[endsect]
Modified: trunk/libs/asio/doc/overview/protocols.qbk
==============================================================================
--- trunk/libs/asio/doc/overview/protocols.qbk (original)
+++ trunk/libs/asio/doc/overview/protocols.qbk 2011-06-05 09:29:41 EDT (Sun, 05 Jun 2011)
@@ -26,10 +26,40 @@
}
The list of endpoints obtained above could contain both IPv4 and IPv6 endpoints,
-so a program may try each of them until it finds one that works. This keeps the
+so a program should try each of them until it finds one that works. This keeps the
client program independent of a specific IP version.
-When an endpoint is available, a socket can be created and connected:
+To simplify the development of protocol-independent programs, TCP clients may
+establish connections using the free functions [link boost_asio.reference.connect
+connect()] and [link boost_asio.reference.async_connect async_connect()]. These
+operations try each endpoint in a list until the socket is successfully
+connected. For example, a single call:
+
+ ip::tcp::socket socket(my_io_service);
+ boost::asio::connect(socket, resolver.resolve(query));
+
+will synchronously try all endpoints until one is successfully connected.
+Similarly, an asynchronous connect may be performed by writing:
+
+ boost::asio::async_connect(socket_, iter,
+ boost::bind(&client::handle_connect, this,
+ boost::asio::placeholders::error));
+
+ // ...
+
+ void handle_connect(const error_code& error)
+ {
+ if (!error)
+ {
+ // Start read or write operations.
+ }
+ else
+ {
+ // Handle error.
+ }
+ }
+
+When a specific endpoint is available, a socket can be created and connected:
ip::tcp::socket socket(my_io_service);
socket.connect(endpoint);
Modified: trunk/libs/asio/doc/overview/reactor.qbk
==============================================================================
--- trunk/libs/asio/doc/overview/reactor.qbk (original)
+++ trunk/libs/asio/doc/overview/reactor.qbk 2011-06-05 09:29:41 EDT (Sun, 05 Jun 2011)
@@ -18,8 +18,7 @@
ip::tcp::socket socket(my_io_service);
...
- ip::tcp::socket::non_blocking nb(true);
- socket.io_control(nb);
+ socket.non_blocking(true);
...
socket.async_read_some(null_buffers(), read_handler);
...
@@ -38,6 +37,8 @@
[heading See Also]
[link boost_asio.reference.null_buffers null_buffers],
+[link boost_asio.reference.basic_socket.non_blocking basic_socket::non_blocking()],
+[link boost_asio.reference.basic_socket.native_non_blocking basic_socket::native_non_blocking()],
[link boost_asio.examples.nonblocking nonblocking example].
[endsect]
Added: trunk/libs/asio/doc/overview/signals.qbk
==============================================================================
--- (empty file)
+++ trunk/libs/asio/doc/overview/signals.qbk 2011-06-05 09:29:41 EDT (Sun, 05 Jun 2011)
@@ -0,0 +1,43 @@
+[/
+ / Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+ /
+ / Distributed under the Boost Software License, Version 1.0. (See accompanying
+ / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ /]
+
+[section:signals Signal Handling]
+
+Boost.Asio supports signal handling using a class called [link
+boost_asio.reference.signal_set 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 be
+registered with multiple [link boost_asio.reference.signal_set signal_set] objects,
+however the signal number must be used only with Boost.Asio.
+
+ void handler(
+ const boost::system::error_code& error,
+ int signal_number)
+ {
+ if (!error)
+ {
+ // A signal occurred.
+ }
+ }
+
+ ...
+
+ // Construct a signal set registered for process termination.
+ boost::asio::signal_set signals(io_service, SIGINT, SIGTERM);
+
+ // Start an asynchronous wait for one of the signals to occur.
+ signals.async_wait(handler);
+
+Signal handling also works on Windows, as the Microsoft Visual C++ runtime
+library maps console events like Ctrl+C to the equivalent signal.
+
+[heading See Also]
+
+[link boost_asio.reference.signal_set signal_set],
+[link boost_asio.examples.http_server HTTP server example].
+
+[endsect]
Modified: trunk/libs/asio/doc/overview/ssl.qbk
==============================================================================
--- trunk/libs/asio/doc/overview/ssl.qbk (original)
+++ trunk/libs/asio/doc/overview/ssl.qbk 2011-06-05 09:29:41 EDT (Sun, 05 Jun 2011)
@@ -51,6 +51,60 @@
async_write()], [link boost_asio.reference.read_until read_until()] or [link
boost_asio.reference.async_read_until async_read_until()] free functions.
+[heading Certificate Verification]
+
+Boost.Asio provides various methods for configuring the way SSL certificates are
+verified:
+
+ * [link boost_asio.reference.ssl__context.set_default_verify_paths ssl::context::set_default_verify_paths()]
+ * [link boost_asio.reference.ssl__context.set_verify_mode ssl::context::set_verify_mode()]
+ * [link boost_asio.reference.ssl__context.set_verify_callback ssl::context::set_verify_callback()]
+ * [link boost_asio.reference.ssl__context.load_verify_file ssl::context::load_verify_file()]
+ * [link boost_asio.reference.ssl__stream.set_verify_mode ssl::stream::set_verify_mode()]
+ * [link boost_asio.reference.ssl__stream.set_verify_callback ssl::stream::set_verify_callback()]
+
+To simplify use cases where certificates are verified according to the rules in
+RFC 2818 (certificate verification for HTTPS), Boost.Asio provides a reusable
+verification callback as a function object:
+
+ * [link boost_asio.reference.ssl__rfc2818_verification ssl::rfc2818_verification]
+
+The following example shows verification of a remote host's certificate
+according to the rules used by HTTPS:
+
+ using boost::asio::ip::tcp;
+ namespace ssl = boost::asio::ssl;
+ typedef ssl::stream<tcp::socket> ssl_socket;
+
+ // Create a context that uses the default paths for
+ // finding CA certificates.
+ ssl::context ctx(ssl::context::sslv23);
+ ctx.set_default_verify_paths();
+
+ // Open a socket and connect it to the remote host.
+ boost::asio::io_service io_service;
+ ssl_socket sock(io_service, ctx);
+ tcp::resolver resolver(io_service);
+ tcp::resolver::query query("host.name", "https");
+ boost::asio::connect(sock.lowest_layer(), resolver.resolve(query));
+ sock.lowest_layer().set_option(tcp::no_delay(true));
+
+ // Perform SSL handshake and verify the remote host's
+ // certificate.
+ sock.set_verify_mode(ssl::verify_peer);
+ sock.set_verify_callback(ssl::rfc2818_verification("host.name"));
+ sock.handshake(ssl_socket::client);
+
+ // ... read and write as normal ...
+
+[heading SSL and Threads]
+
+SSL stream objects perform no locking of their own. Therefore, it is essential
+that all asynchronous SSL operations are performed in an implicit or explicit
+[link boost_asio.overview.core.strands strand]. Note that this means that no
+synchronisation is required (and so no locking overhead is incurred) in single
+threaded programs.
+
[heading See Also]
[link boost_asio.reference.ssl__context ssl::context],
Modified: trunk/libs/asio/doc/reference.dox
==============================================================================
--- trunk/libs/asio/doc/reference.dox (original)
+++ trunk/libs/asio/doc/reference.dox 2011-06-05 09:29:41 EDT (Sun, 05 Jun 2011)
@@ -193,7 +193,8 @@
BOOST_ASIO_SOCKET_ERROR(e)=implementation_defined \
BOOST_ASIO_NETDB_ERROR(e)=implementation_defined \
BOOST_ASIO_EOF_ERROR(e)=implementation_defined \
- BOOST_ASIO_OS_ERROR(e1,e2)=implementation_defined
+ BOOST_ASIO_OS_ERROR(e1,e2)=implementation_defined \
+ BOOST_ASIO_MOVE_ARG(a)=a
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
Modified: trunk/libs/asio/doc/reference.qbk
==============================================================================
--- trunk/libs/asio/doc/reference.qbk (original)
+++ trunk/libs/asio/doc/reference.qbk 2011-06-05 09:29:41 EDT (Sun, 05 Jun 2011)
@@ -43196,6 +43196,27 @@
The `boost::asio::buffer_cast` function permits violations of type safety, so uses of it in application code should be carefully considered.
+For convenience, the [link boost_asio.reference.buffer_size `buffer_size`] function also works on buffer sequences (that is, types meeting the ConstBufferSequence or MutableBufferSequence type requirements). In this case, the function returns the total size of all buffers in the sequence.
+
+
+[heading Buffer Copying]
+
+
+
+The [link boost_asio.reference.buffer_copy `buffer_copy`] function may be used to copy raw bytes between individual buffers and buffer sequences.
+
+In particular, when used with the [link boost_asio.reference.buffer_size `buffer_size`] , the [link boost_asio.reference.buffer_copy `buffer_copy`] function can be used to linearise a sequence of buffers. For example:
+
+
+
+ vector<const_buffer> buffers = ...;
+
+ vector<unsigned char> data(boost::asio::buffer_size(buffers));
+ boost::asio::buffer_copy(boost::asio::buffer(data), buffers);
+
+
+
+
[heading Buffer Invalidation]
@@ -61635,11 +61656,11 @@
template<
- typename ``[link boost_asio.reference.Handler Handler]``>
+ typename ``[link boost_asio.reference.ResolveHandler ResolveHandler]``>
void ``[link boost_asio.reference.ip__resolver_service.async_resolve.overload1 async_resolve]``(
implementation_type & impl,
const query_type & query,
- Handler handler);
+ ResolveHandler handler);
`` [''''»''' [link boost_asio.reference.ip__resolver_service.async_resolve.overload1 more...]]``
@@ -61662,11 +61683,11 @@
template<
- typename ``[link boost_asio.reference.Handler Handler]``>
+ typename ``[link boost_asio.reference.ResolveHandler ResolveHandler]``>
void async_resolve(
implementation_type & impl,
const query_type & query,
- Handler handler);
+ ResolveHandler handler);
Modified: trunk/libs/asio/doc/tutorial.qbk
==============================================================================
--- trunk/libs/asio/doc/tutorial.qbk (original)
+++ trunk/libs/asio/doc/tutorial.qbk 2011-06-05 09:29:41 EDT (Sun, 05 Jun 2011)
@@ -205,7 +205,7 @@
Next, instead of doing a blocking wait as in tutorial Timer.1, we call the [link boost_asio.reference.basic_deadline_timer.async_wait deadline_timer::async_wait()] function to perform an asynchronous wait. When calling this function we pass the `print` callback handler that was defined above.
- ``''''''`` t.async_wait(print);
+ ``''''''`` t.async_wait(&print);
@@ -262,7 +262,7 @@
``''''''`` boost::asio::io_service io;
``''''''`` boost::asio::deadline_timer t(io, boost::posix_time::seconds(5));
- ``''''''`` t.async_wait(print);
+ ``''''''`` t.async_wait(&print);
``''''''`` io.run();
@@ -1255,8 +1255,9 @@
``''''''`` if (!error)
``''''''`` {
``''''''`` new_connection->start();
- ``''''''`` start_accept();
``''''''`` }
+
+ ``''''''`` start_accept();
``''''''`` }
@@ -1459,8 +1460,9 @@
``''''''`` if (!error)
``''''''`` {
``''''''`` new_connection->start();
- ``''''''`` start_accept();
``''''''`` }
+
+ ``''''''`` start_accept();
``''''''`` }
``''''''`` tcp::acceptor acceptor_;
@@ -2156,8 +2158,9 @@
``''''''`` if (!error)
``''''''`` {
``''''''`` new_connection->start();
- ``''''''`` start_accept();
``''''''`` }
+
+ ``''''''`` start_accept();
``''''''`` }
``''''''`` tcp::acceptor acceptor_;
@@ -2317,8 +2320,9 @@
``''''''`` if (!error)
``''''''`` {
``''''''`` new_connection->start();
- ``''''''`` start_accept();
``''''''`` }
+
+ ``''''''`` start_accept();
``''''''`` }
``''''''`` tcp::acceptor acceptor_;
Modified: trunk/libs/asio/example/timers/tick_count_timer.cpp
==============================================================================
--- trunk/libs/asio/example/timers/tick_count_timer.cpp (original)
+++ trunk/libs/asio/example/timers/tick_count_timer.cpp 2011-06-05 09:29:41 EDT (Sun, 05 Jun 2011)
@@ -31,15 +31,17 @@
DWORD ticks_;
};
- // The duration type.
+ // The duration type. According to the TimeTraits requirements, the duration
+ // must be a signed type. This means we can't handle durations larger than
+ // 2^31.
class duration_type
{
public:
duration_type() : ticks_(0) {}
- duration_type(DWORD ticks) : ticks_(ticks) {}
+ duration_type(LONG ticks) : ticks_(ticks) {}
private:
friend struct tick_count_traits;
- DWORD ticks_;
+ LONG ticks_;
};
// Get the current time.
@@ -61,7 +63,12 @@
// Subtract one time from another.
static duration_type subtract(const time_type& t1, const time_type& t2)
{
- return duration_type(t1.ticks_ - t2.ticks_);
+ // DWORD tick count values can wrap (see less_than() below). We'll convert
+ // to a duration by taking the absolute difference and adding the sign
+ // based on which is the "lesser" absolute time.
+ return duration_type(less_than(t1, t2)
+ ? -static_cast<LONG>(t2.ticks_ - t1.ticks_)
+ : static_cast<LONG>(t1.ticks_ - t2.ticks_));
}
// Test whether one time is less than another.
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk