Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69194 - in trunk: boost boost/asio boost/asio/detail boost/asio/detail/impl boost/asio/impl boost/asio/ip boost/asio/ip/detail boost/asio/ip/detail/impl boost/asio/ip/impl boost/asio/local boost/asio/local/detail boost/asio/local/detail/impl boost/asio/posix boost/asio/ssl boost/asio/ssl/detail boost/asio/ssl/impl boost/asio/windows libs/asio/doc libs/asio/doc/overview libs/asio/doc/requirements libs/asio/example/chat libs/asio/example/echo libs/asio/example/http/client libs/asio/example/http/server2 libs/asio/example/iostreams libs/asio/example/local libs/asio/example/nonblocking libs/asio/example/porthopper libs/asio/example/serialization libs/asio/example/services libs/asio/example/socks4 libs/asio/example/ssl libs/asio/example/timeouts libs/asio/example/tutorial libs/asio/example/tutorial/daytime1 libs/asio/example/tutorial/daytime2 libs/asio/example/tutorial/daytime3 libs/asio/example/tutorial/daytime4 libs/asio/example/tutorial/daytime7 libs/asio/example/windows libs/asio/test libs/asio/test/ip libs/asio/test/local libs/asio/test/posix libs/asio/test/ssl libs/asio/test/windows
From: chris_at_[hidden]
Date: 2011-02-22 20:06:25


Author: chris_kohlhoff
Date: 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
New Revision: 69194
URL: http://svn.boost.org/trac/boost/changeset/69194

Log:
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.

Added:
   trunk/boost/asio/basic_seq_packet_socket.hpp (contents, props changed)
   trunk/boost/asio/connect.hpp (contents, props changed)
   trunk/boost/asio/detail/handler_type_requirements.hpp (contents, props changed)
   trunk/boost/asio/detail/reactive_socket_recvmsg_op.hpp (contents, props changed)
   trunk/boost/asio/detail/win_iocp_socket_recvmsg_op.hpp (contents, props changed)
   trunk/boost/asio/impl/connect.hpp (contents, props changed)
   trunk/boost/asio/seq_packet_socket_service.hpp (contents, props changed)
   trunk/boost/asio/ssl/error.hpp (contents, props changed)
   trunk/boost/asio/ssl/impl/
   trunk/boost/asio/ssl/impl/error.ipp (contents, props changed)
   trunk/boost/asio/ssl/impl/src.hpp (contents, props changed)
   trunk/libs/asio/doc/requirements/ComposedConnectHandler.qbk (contents, props changed)
   trunk/libs/asio/doc/requirements/SeqPacketSocketService.qbk (contents, props changed)
   trunk/libs/asio/example/iostreams/http_client.cpp (contents, props changed)
   trunk/libs/asio/test/basic_raw_socket.cpp (contents, props changed)
   trunk/libs/asio/test/basic_seq_packet_socket.cpp (contents, props changed)
   trunk/libs/asio/test/connect.cpp (contents, props changed)
   trunk/libs/asio/test/raw_socket_service.cpp (contents, props changed)
   trunk/libs/asio/test/seq_packet_socket_service.cpp (contents, props changed)
Text files modified:
   trunk/boost/asio.hpp | 3
   trunk/boost/asio/basic_datagram_socket.hpp | 61
   trunk/boost/asio/basic_deadline_timer.hpp | 69
   trunk/boost/asio/basic_io_object.hpp | 14
   trunk/boost/asio/basic_raw_socket.hpp | 61
   trunk/boost/asio/basic_serial_port.hpp | 43
   trunk/boost/asio/basic_socket.hpp | 363
   trunk/boost/asio/basic_socket_acceptor.hpp | 221
   trunk/boost/asio/basic_socket_iostream.hpp | 98
   trunk/boost/asio/basic_socket_streambuf.hpp | 328
   trunk/boost/asio/basic_stream_socket.hpp | 51
   trunk/boost/asio/basic_streambuf.hpp | 4
   trunk/boost/asio/buffer.hpp | 1218
   trunk/boost/asio/buffered_read_stream.hpp | 99
   trunk/boost/asio/buffered_stream.hpp | 7
   trunk/boost/asio/buffered_write_stream.hpp | 87
   trunk/boost/asio/completion_condition.hpp | 56
   trunk/boost/asio/datagram_socket_service.hpp | 49
   trunk/boost/asio/deadline_timer_service.hpp | 7
   trunk/boost/asio/detail/bind_handler.hpp | 43
   trunk/boost/asio/detail/buffer_sequence_adapter.hpp | 60
   trunk/boost/asio/detail/buffered_stream_storage.hpp | 19
   trunk/boost/asio/detail/completion_handler.hpp | 6
   trunk/boost/asio/detail/config.hpp | 35
   trunk/boost/asio/detail/deadline_timer_service.hpp | 26
   trunk/boost/asio/detail/descriptor_ops.hpp | 10
   trunk/boost/asio/detail/descriptor_read_op.hpp | 4
   trunk/boost/asio/detail/descriptor_write_op.hpp | 4
   trunk/boost/asio/detail/dev_poll_reactor.hpp | 10
   trunk/boost/asio/detail/epoll_reactor.hpp | 10
   trunk/boost/asio/detail/hash_map.hpp | 36
   trunk/boost/asio/detail/impl/descriptor_ops.ipp | 64
   trunk/boost/asio/detail/impl/dev_poll_reactor.hpp | 5
   trunk/boost/asio/detail/impl/dev_poll_reactor.ipp | 4
   trunk/boost/asio/detail/impl/epoll_reactor.hpp | 5
   trunk/boost/asio/detail/impl/epoll_reactor.ipp | 16
   trunk/boost/asio/detail/impl/kqueue_reactor.hpp | 5
   trunk/boost/asio/detail/impl/kqueue_reactor.ipp | 20
   trunk/boost/asio/detail/impl/reactive_descriptor_service.ipp | 35
   trunk/boost/asio/detail/impl/reactive_serial_port_service.ipp | 6
   trunk/boost/asio/detail/impl/reactive_socket_service_base.ipp | 19
   trunk/boost/asio/detail/impl/select_reactor.hpp | 5
   trunk/boost/asio/detail/impl/select_reactor.ipp | 4
   trunk/boost/asio/detail/impl/service_registry.ipp | 2
   trunk/boost/asio/detail/impl/socket_ops.ipp | 183
   trunk/boost/asio/detail/impl/strand_service.hpp | 4
   trunk/boost/asio/detail/impl/task_io_service.hpp | 4
   trunk/boost/asio/detail/impl/task_io_service.ipp | 6
   trunk/boost/asio/detail/impl/timer_queue.ipp | 4
   trunk/boost/asio/detail/impl/win_iocp_handle_service.ipp | 6
   trunk/boost/asio/detail/impl/win_iocp_io_service.hpp | 9
   trunk/boost/asio/detail/impl/win_iocp_serial_port_service.ipp | 6
   trunk/boost/asio/detail/impl/win_iocp_socket_service_base.ipp | 6
   trunk/boost/asio/detail/impl/win_thread.ipp | 13
   trunk/boost/asio/detail/io_control.hpp | 4
   trunk/boost/asio/detail/kqueue_reactor.hpp | 8
   trunk/boost/asio/detail/old_win_sdk_compat.hpp | 124
   trunk/boost/asio/detail/posix_thread.hpp | 2
   trunk/boost/asio/detail/reactive_descriptor_service.hpp | 50
   trunk/boost/asio/detail/reactive_null_buffers_op.hpp | 4
   trunk/boost/asio/detail/reactive_serial_port_service.hpp | 15
   trunk/boost/asio/detail/reactive_socket_accept_op.hpp | 4
   trunk/boost/asio/detail/reactive_socket_connect_op.hpp | 4
   trunk/boost/asio/detail/reactive_socket_recv_op.hpp | 4
   trunk/boost/asio/detail/reactive_socket_recvfrom_op.hpp | 4
   trunk/boost/asio/detail/reactive_socket_send_op.hpp | 4
   trunk/boost/asio/detail/reactive_socket_sendto_op.hpp | 4
   trunk/boost/asio/detail/reactive_socket_service.hpp | 22
   trunk/boost/asio/detail/reactive_socket_service_base.hpp | 122
   trunk/boost/asio/detail/resolve_endpoint_op.hpp | 4
   trunk/boost/asio/detail/resolve_op.hpp | 4
   trunk/boost/asio/detail/resolver_service.hpp | 8
   trunk/boost/asio/detail/select_reactor.hpp | 12
   trunk/boost/asio/detail/socket_ops.hpp | 31
   trunk/boost/asio/detail/socket_types.hpp | 2
   trunk/boost/asio/detail/strand_service.hpp | 4
   trunk/boost/asio/detail/task_io_service.hpp | 9
   trunk/boost/asio/detail/timer_queue.hpp | 16
   trunk/boost/asio/detail/win_iocp_handle_read_op.hpp | 5
   trunk/boost/asio/detail/win_iocp_handle_service.hpp | 16
   trunk/boost/asio/detail/win_iocp_handle_write_op.hpp | 4
   trunk/boost/asio/detail/win_iocp_io_service.hpp | 16
   trunk/boost/asio/detail/win_iocp_null_buffers_op.hpp | 4
   trunk/boost/asio/detail/win_iocp_overlapped_op.hpp | 4
   trunk/boost/asio/detail/win_iocp_overlapped_ptr.hpp | 4
   trunk/boost/asio/detail/win_iocp_serial_port_service.hpp | 14
   trunk/boost/asio/detail/win_iocp_socket_accept_op.hpp | 6
   trunk/boost/asio/detail/win_iocp_socket_recv_op.hpp | 4
   trunk/boost/asio/detail/win_iocp_socket_recvfrom_op.hpp | 4
   trunk/boost/asio/detail/win_iocp_socket_send_op.hpp | 4
   trunk/boost/asio/detail/win_iocp_socket_service.hpp | 26
   trunk/boost/asio/detail/win_iocp_socket_service_base.hpp | 110
   trunk/boost/asio/detail/wince_thread.hpp | 2
   trunk/boost/asio/detail/wrapped_handler.hpp | 2
   trunk/boost/asio/error.hpp | 24
   trunk/boost/asio/impl/error.ipp | 26
   trunk/boost/asio/impl/io_service.hpp | 27
   trunk/boost/asio/impl/io_service.ipp | 5
   trunk/boost/asio/impl/read.hpp | 54
   trunk/boost/asio/impl/read_at.hpp | 55
   trunk/boost/asio/impl/read_until.hpp | 65
   trunk/boost/asio/impl/write.hpp | 57
   trunk/boost/asio/impl/write_at.hpp | 58
   trunk/boost/asio/io_service.hpp | 48
   trunk/boost/asio/ip/address.hpp | 9
   trunk/boost/asio/ip/address_v4.hpp | 12
   trunk/boost/asio/ip/basic_endpoint.hpp | 9
   trunk/boost/asio/ip/basic_resolver.hpp | 17
   trunk/boost/asio/ip/basic_resolver_entry.hpp | 10
   trunk/boost/asio/ip/basic_resolver_query.hpp | 69
   trunk/boost/asio/ip/detail/endpoint.hpp | 5
   trunk/boost/asio/ip/detail/impl/endpoint.ipp | 14
   trunk/boost/asio/ip/detail/socket_option.hpp | 38
   trunk/boost/asio/ip/icmp.hpp | 12
   trunk/boost/asio/ip/impl/address.ipp | 21
   trunk/boost/asio/ip/impl/address_v4.ipp | 18
   trunk/boost/asio/ip/impl/address_v6.ipp | 66
   trunk/boost/asio/ip/tcp.hpp | 10
   trunk/boost/asio/ip/udp.hpp | 10
   trunk/boost/asio/local/basic_endpoint.hpp | 12
   trunk/boost/asio/local/detail/endpoint.hpp | 4
   trunk/boost/asio/local/detail/impl/endpoint.ipp | 20
   trunk/boost/asio/posix/basic_descriptor.hpp | 160
   trunk/boost/asio/posix/basic_stream_descriptor.hpp | 24
   trunk/boost/asio/posix/descriptor_base.hpp | 3
   trunk/boost/asio/posix/stream_descriptor_service.hpp | 67
   trunk/boost/asio/raw_socket_service.hpp | 49
   trunk/boost/asio/read.hpp | 68
   trunk/boost/asio/read_at.hpp | 79
   trunk/boost/asio/serial_port_service.hpp | 25
   trunk/boost/asio/socket_acceptor_service.hpp | 49
   trunk/boost/asio/socket_base.hpp | 8
   trunk/boost/asio/ssl.hpp | 1
   trunk/boost/asio/ssl/detail/openssl_operation.hpp | 1
   trunk/boost/asio/ssl/stream.hpp | 14
   trunk/boost/asio/strand.hpp | 31
   trunk/boost/asio/stream_socket_service.hpp | 49
   trunk/boost/asio/version.hpp | 2
   trunk/boost/asio/windows/basic_handle.hpp | 39
   trunk/boost/asio/windows/basic_random_access_handle.hpp | 30
   trunk/boost/asio/windows/basic_stream_handle.hpp | 29
   trunk/boost/asio/windows/random_access_handle_service.hpp | 25
   trunk/boost/asio/windows/stream_handle_service.hpp | 25
   trunk/boost/asio/write.hpp | 70
   trunk/boost/asio/write_at.hpp | 79
   trunk/libs/asio/doc/asio.qbk | 11
   trunk/libs/asio/doc/examples.qbk | 8
   trunk/libs/asio/doc/overview/basics.qbk | 12
   trunk/libs/asio/doc/overview/implementation.qbk | 4
   trunk/libs/asio/doc/overview/serial_ports.qbk | 11
   trunk/libs/asio/doc/overview/ssl.qbk | 5
   trunk/libs/asio/doc/quickref.xml | 12
   trunk/libs/asio/doc/reference.qbk | 60301 ++++++++++++++++++++++++---------------
   trunk/libs/asio/doc/reference.xsl | 8
   trunk/libs/asio/doc/requirements/AsyncReadStream.qbk | 4
   trunk/libs/asio/doc/requirements/AsyncWriteStream.qbk | 4
   trunk/libs/asio/doc/requirements/DatagramSocketService.qbk | 8
   trunk/libs/asio/doc/requirements/DescriptorService.qbk | 10
   trunk/libs/asio/doc/requirements/HandleService.qbk | 10
   trunk/libs/asio/doc/requirements/RawSocketService.qbk | 8
   trunk/libs/asio/doc/requirements/ResolverService.qbk | 4
   trunk/libs/asio/doc/requirements/SerialPortService.qbk | 10
   trunk/libs/asio/doc/requirements/SocketAcceptorService.qbk | 22
   trunk/libs/asio/doc/requirements/SocketService.qbk | 20
   trunk/libs/asio/doc/requirements/StreamDescriptorService.qbk | 4
   trunk/libs/asio/doc/requirements/StreamHandleService.qbk | 4
   trunk/libs/asio/doc/requirements/StreamSocketService.qbk | 4
   trunk/libs/asio/doc/requirements/TimerService.qbk | 2
   trunk/libs/asio/doc/requirements/asynchronous_operations.qbk | 10
   trunk/libs/asio/doc/tutorial.qbk | 42
   trunk/libs/asio/doc/using.qbk | 3
   trunk/libs/asio/example/chat/chat_client.cpp | 16
   trunk/libs/asio/example/chat/chat_message.hpp | 4
   trunk/libs/asio/example/chat/posix_chat_client.cpp | 18
   trunk/libs/asio/example/echo/blocking_tcp_echo_client.cpp | 2
   trunk/libs/asio/example/http/client/async_client.cpp | 21
   trunk/libs/asio/example/http/client/sync_client.cpp | 11
   trunk/libs/asio/example/http/server2/server.cpp | 2
   trunk/libs/asio/example/iostreams/Jamfile | 12
   trunk/libs/asio/example/iostreams/Jamfile.v2 | 1
   trunk/libs/asio/example/iostreams/daytime_client.cpp | 6
   trunk/libs/asio/example/local/iostream_client.cpp | 2
   trunk/libs/asio/example/nonblocking/third_party_lib.cpp | 5
   trunk/libs/asio/example/porthopper/protocol.hpp | 19
   trunk/libs/asio/example/serialization/client.cpp | 17
   trunk/libs/asio/example/serialization/connection.hpp | 2
   trunk/libs/asio/example/serialization/server.cpp | 4
   trunk/libs/asio/example/services/daytime_client.cpp | 16
   trunk/libs/asio/example/services/logger_service.hpp | 2
   trunk/libs/asio/example/services/stream_socket_service.hpp | 4
   trunk/libs/asio/example/socks4/sync_client.cpp | 11
   trunk/libs/asio/example/ssl/client.cpp | 16
   trunk/libs/asio/example/timeouts/blocking_tcp_client.cpp | 62
   trunk/libs/asio/example/tutorial/daytime1/client.cpp | 10
   trunk/libs/asio/example/tutorial/daytime2/server.cpp | 3
   trunk/libs/asio/example/tutorial/daytime3/server.cpp | 2
   trunk/libs/asio/example/tutorial/daytime4/client.cpp | 2
   trunk/libs/asio/example/tutorial/daytime7/server.cpp | 2
   trunk/libs/asio/example/tutorial/daytime_dox.txt | 10
   trunk/libs/asio/example/windows/transmit_file.cpp | 6
   trunk/libs/asio/test/Jamfile | 5
   trunk/libs/asio/test/Jamfile.v2 | 10
   trunk/libs/asio/test/buffer.cpp | 103
   trunk/libs/asio/test/deadline_timer.cpp | 31
   trunk/libs/asio/test/io_service.cpp | 20
   trunk/libs/asio/test/ip/address.cpp | 100
   trunk/libs/asio/test/ip/address_v4.cpp | 141
   trunk/libs/asio/test/ip/address_v6.cpp | 220
   trunk/libs/asio/test/ip/tcp.cpp | 21
   trunk/libs/asio/test/ip/udp.cpp | 18
   trunk/libs/asio/test/local/datagram_protocol.cpp | 2
   trunk/libs/asio/test/local/stream_protocol.cpp | 2
   trunk/libs/asio/test/posix/stream_descriptor.cpp | 20
   trunk/libs/asio/test/read.cpp | 1085
   trunk/libs/asio/test/read_at.cpp | 3215 +
   trunk/libs/asio/test/read_until.cpp | 26
   trunk/libs/asio/test/serial_port.cpp | 11
   trunk/libs/asio/test/ssl/stream.cpp | 2
   trunk/libs/asio/test/windows/random_access_handle.cpp | 6
   trunk/libs/asio/test/windows/stream_handle.cpp | 6
   trunk/libs/asio/test/write.cpp | 965
   trunk/libs/asio/test/write_at.cpp | 2560 +
   222 files changed, 49653 insertions(+), 25670 deletions(-)

Modified: trunk/boost/asio.hpp
==============================================================================
--- trunk/boost/asio.hpp (original)
+++ trunk/boost/asio.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -21,6 +21,7 @@
 #include <boost/asio/basic_deadline_timer.hpp>
 #include <boost/asio/basic_io_object.hpp>
 #include <boost/asio/basic_raw_socket.hpp>
+#include <boost/asio/basic_seq_packet_socket.hpp>
 #include <boost/asio/basic_serial_port.hpp>
 #include <boost/asio/basic_socket_acceptor.hpp>
 #include <boost/asio/basic_socket_iostream.hpp>
@@ -36,6 +37,7 @@
 #include <boost/asio/buffered_write_stream.hpp>
 #include <boost/asio/buffers_iterator.hpp>
 #include <boost/asio/completion_condition.hpp>
+#include <boost/asio/connect.hpp>
 #include <boost/asio/datagram_socket_service.hpp>
 #include <boost/asio/deadline_timer_service.hpp>
 #include <boost/asio/deadline_timer.hpp>
@@ -76,6 +78,7 @@
 #include <boost/asio/read.hpp>
 #include <boost/asio/read_at.hpp>
 #include <boost/asio/read_until.hpp>
+#include <boost/asio/seq_packet_socket_service.hpp>
 #include <boost/asio/serial_port.hpp>
 #include <boost/asio/serial_port_base.hpp>
 #include <boost/asio/serial_port_service.hpp>

Modified: trunk/boost/asio/basic_datagram_socket.hpp
==============================================================================
--- trunk/boost/asio/basic_datagram_socket.hpp (original)
+++ trunk/boost/asio/basic_datagram_socket.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -19,6 +19,7 @@
 #include <cstddef>
 #include <boost/asio/basic_socket.hpp>
 #include <boost/asio/datagram_socket_service.hpp>
+#include <boost/asio/detail/handler_type_requirements.hpp>
 #include <boost/asio/detail/throw_error.hpp>
 #include <boost/asio/error.hpp>
 
@@ -42,8 +43,12 @@
   : public basic_socket<Protocol, DatagramSocketService>
 {
 public:
+ /// (Deprecated: Use native_handle_type.) The native representation of a
+ /// socket.
+ typedef typename DatagramSocketService::native_handle_type native_type;
+
   /// The native representation of a socket.
- typedef typename DatagramSocketService::native_type native_type;
+ typedef typename DatagramSocketService::native_handle_type native_handle_type;
 
   /// The protocol type.
   typedef Protocol protocol_type;
@@ -121,7 +126,7 @@
    * @throws boost::system::system_error Thrown on failure.
    */
   basic_datagram_socket(boost::asio::io_service& io_service,
- const protocol_type& protocol, const native_type& native_socket)
+ const protocol_type& protocol, const native_handle_type& native_socket)
     : basic_socket<Protocol, DatagramSocketService>(
         io_service, protocol, native_socket)
   {
@@ -249,7 +254,12 @@
   template <typename ConstBufferSequence, typename WriteHandler>
   void async_send(const ConstBufferSequence& buffers, WriteHandler handler)
   {
- this->service.async_send(this->implementation, buffers, 0, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a WriteHandler.
+ BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
+
+ this->service.async_send(this->implementation, buffers, 0,
+ BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
   /// Start an asynchronous send on a connected socket.
@@ -285,7 +295,12 @@
   void async_send(const ConstBufferSequence& buffers,
       socket_base::message_flags flags, WriteHandler handler)
   {
- this->service.async_send(this->implementation, buffers, flags, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a WriteHandler.
+ BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
+
+ this->service.async_send(this->implementation, buffers, flags,
+ BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
   /// Send a datagram to the specified endpoint.
@@ -417,8 +432,12 @@
   void async_send_to(const ConstBufferSequence& buffers,
       const endpoint_type& destination, WriteHandler handler)
   {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a WriteHandler.
+ BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
+
     this->service.async_send_to(this->implementation, buffers, destination, 0,
- handler);
+ BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
   /// Start an asynchronous send.
@@ -453,8 +472,12 @@
       const endpoint_type& destination, socket_base::message_flags flags,
       WriteHandler handler)
   {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a WriteHandler.
+ BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
+
     this->service.async_send_to(this->implementation, buffers, destination,
- flags, handler);
+ flags, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
   /// Receive some data on a connected socket.
@@ -584,7 +607,12 @@
   template <typename MutableBufferSequence, typename ReadHandler>
   void async_receive(const MutableBufferSequence& buffers, ReadHandler handler)
   {
- this->service.async_receive(this->implementation, buffers, 0, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
+ this->service.async_receive(this->implementation, buffers, 0,
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 
   /// Start an asynchronous receive on a connected socket.
@@ -619,7 +647,12 @@
   void async_receive(const MutableBufferSequence& buffers,
       socket_base::message_flags flags, ReadHandler handler)
   {
- this->service.async_receive(this->implementation, buffers, flags, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
+ this->service.async_receive(this->implementation, buffers, flags,
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 
   /// Receive a datagram with the endpoint of the sender.
@@ -751,8 +784,12 @@
   void async_receive_from(const MutableBufferSequence& buffers,
       endpoint_type& sender_endpoint, ReadHandler handler)
   {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
     this->service.async_receive_from(this->implementation, buffers,
- sender_endpoint, 0, handler);
+ sender_endpoint, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 
   /// Start an asynchronous receive.
@@ -789,8 +826,12 @@
       endpoint_type& sender_endpoint, socket_base::message_flags flags,
       ReadHandler handler)
   {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
     this->service.async_receive_from(this->implementation, buffers,
- sender_endpoint, flags, handler);
+ sender_endpoint, flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 };
 

Modified: trunk/boost/asio/basic_deadline_timer.hpp
==============================================================================
--- trunk/boost/asio/basic_deadline_timer.hpp (original)
+++ trunk/boost/asio/basic_deadline_timer.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -19,6 +19,7 @@
 #include <cstddef>
 #include <boost/asio/basic_io_object.hpp>
 #include <boost/asio/deadline_timer_service.hpp>
+#include <boost/asio/detail/handler_type_requirements.hpp>
 #include <boost/asio/detail/throw_error.hpp>
 #include <boost/asio/error.hpp>
 
@@ -240,6 +241,67 @@
     return this->service.cancel(this->implementation, ec);
   }
 
+ /// Cancels one asynchronous operation that is waiting on the timer.
+ /**
+ * This function forces the completion of one pending asynchronous wait
+ * operation against the timer. Handlers are cancelled in FIFO order. The
+ * handler for the cancelled operation will be invoked with the
+ * boost::asio::error::operation_aborted error code.
+ *
+ * Cancelling the timer does not change the expiry time.
+ *
+ * @return The number of asynchronous operations that were cancelled. That is,
+ * either 0 or 1.
+ *
+ * @throws boost::system::system_error Thrown on failure.
+ *
+ * @note If the timer has already expired when cancel_one() is called, then
+ * the handlers for asynchronous wait operations will:
+ *
+ * @li have already been invoked; or
+ *
+ * @li have been queued for invocation in the near future.
+ *
+ * These handlers can no longer be cancelled, and therefore are passed an
+ * error code that indicates the successful completion of the wait operation.
+ */
+ std::size_t cancel_one()
+ {
+ boost::system::error_code ec;
+ std::size_t s = this->service.cancel_one(this->implementation, ec);
+ boost::asio::detail::throw_error(ec);
+ return s;
+ }
+
+ /// Cancels one asynchronous operation that is waiting on the timer.
+ /**
+ * This function forces the completion of one pending asynchronous wait
+ * operation against the timer. Handlers are cancelled in FIFO order. The
+ * handler for the cancelled operation will be invoked with the
+ * boost::asio::error::operation_aborted error code.
+ *
+ * Cancelling the timer does not change the expiry time.
+ *
+ * @param ec Set to indicate what error occurred, if any.
+ *
+ * @return The number of asynchronous operations that were cancelled. That is,
+ * either 0 or 1.
+ *
+ * @note If the timer has already expired when cancel_one() is called, then
+ * the handlers for asynchronous wait operations will:
+ *
+ * @li have already been invoked; or
+ *
+ * @li have been queued for invocation in the near future.
+ *
+ * These handlers can no longer be cancelled, and therefore are passed an
+ * error code that indicates the successful completion of the wait operation.
+ */
+ std::size_t cancel_one(boost::system::error_code& ec)
+ {
+ return this->service.cancel_one(this->implementation, ec);
+ }
+
   /// Get the timer's expiry time as an absolute time.
   /**
    * This function may be used to obtain the timer's current expiry time.
@@ -432,7 +494,12 @@
   template <typename WaitHandler>
   void async_wait(WaitHandler handler)
   {
- this->service.async_wait(this->implementation, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a WaitHandler.
+ BOOST_ASIO_WAIT_HANDLER_CHECK(WaitHandler, handler) type_check;
+
+ this->service.async_wait(this->implementation,
+ BOOST_ASIO_MOVE_CAST(WaitHandler)(handler));
   }
 };
 

Modified: trunk/boost/asio/basic_io_object.hpp
==============================================================================
--- trunk/boost/asio/basic_io_object.hpp (original)
+++ trunk/boost/asio/basic_io_object.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -36,20 +36,6 @@
   /// The underlying implementation type of I/O object.
   typedef typename service_type::implementation_type implementation_type;
 
- /// (Deprecated: use get_io_service().) Get the io_service associated with
- /// the object.
- /**
- * This function may be used to obtain the io_service object that the I/O
- * object uses to dispatch handlers for asynchronous operations.
- *
- * @return A reference to the io_service object that the I/O object will use
- * to dispatch handlers. Ownership is not transferred to the caller.
- */
- boost::asio::io_service& io_service()
- {
- return service.get_io_service();
- }
-
   /// Get the io_service associated with the object.
   /**
    * This function may be used to obtain the io_service object that the I/O

Modified: trunk/boost/asio/basic_raw_socket.hpp
==============================================================================
--- trunk/boost/asio/basic_raw_socket.hpp (original)
+++ trunk/boost/asio/basic_raw_socket.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -18,6 +18,7 @@
 #include <boost/asio/detail/config.hpp>
 #include <cstddef>
 #include <boost/asio/basic_socket.hpp>
+#include <boost/asio/detail/handler_type_requirements.hpp>
 #include <boost/asio/detail/throw_error.hpp>
 #include <boost/asio/error.hpp>
 #include <boost/asio/raw_socket_service.hpp>
@@ -42,8 +43,12 @@
   : public basic_socket<Protocol, RawSocketService>
 {
 public:
+ /// (Deprecated: Use native_handle_type.) The native representation of a
+ /// socket.
+ typedef typename RawSocketService::native_handle_type native_type;
+
   /// The native representation of a socket.
- typedef typename RawSocketService::native_type native_type;
+ typedef typename RawSocketService::native_handle_type native_handle_type;
 
   /// The protocol type.
   typedef Protocol protocol_type;
@@ -121,7 +126,7 @@
    * @throws boost::system::system_error Thrown on failure.
    */
   basic_raw_socket(boost::asio::io_service& io_service,
- const protocol_type& protocol, const native_type& native_socket)
+ const protocol_type& protocol, const native_handle_type& native_socket)
     : basic_socket<Protocol, RawSocketService>(
         io_service, protocol, native_socket)
   {
@@ -245,7 +250,12 @@
   template <typename ConstBufferSequence, typename WriteHandler>
   void async_send(const ConstBufferSequence& buffers, WriteHandler handler)
   {
- this->service.async_send(this->implementation, buffers, 0, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a WriteHandler.
+ BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
+
+ this->service.async_send(this->implementation, buffers, 0,
+ BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
   /// Start an asynchronous send on a connected socket.
@@ -280,7 +290,12 @@
   void async_send(const ConstBufferSequence& buffers,
       socket_base::message_flags flags, WriteHandler handler)
   {
- this->service.async_send(this->implementation, buffers, flags, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a WriteHandler.
+ BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
+
+ this->service.async_send(this->implementation, buffers, flags,
+ BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
   /// Send raw data to the specified endpoint.
@@ -412,8 +427,12 @@
   void async_send_to(const ConstBufferSequence& buffers,
       const endpoint_type& destination, WriteHandler handler)
   {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a WriteHandler.
+ BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
+
     this->service.async_send_to(this->implementation, buffers, destination, 0,
- handler);
+ BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
   /// Start an asynchronous send.
@@ -448,8 +467,12 @@
       const endpoint_type& destination, socket_base::message_flags flags,
       WriteHandler handler)
   {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a WriteHandler.
+ BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
+
     this->service.async_send_to(this->implementation, buffers, destination,
- flags, handler);
+ flags, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
   /// Receive some data on a connected socket.
@@ -579,7 +602,12 @@
   template <typename MutableBufferSequence, typename ReadHandler>
   void async_receive(const MutableBufferSequence& buffers, ReadHandler handler)
   {
- this->service.async_receive(this->implementation, buffers, 0, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
+ this->service.async_receive(this->implementation, buffers, 0,
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 
   /// Start an asynchronous receive on a connected socket.
@@ -614,7 +642,12 @@
   void async_receive(const MutableBufferSequence& buffers,
       socket_base::message_flags flags, ReadHandler handler)
   {
- this->service.async_receive(this->implementation, buffers, flags, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
+ this->service.async_receive(this->implementation, buffers, flags,
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 
   /// Receive raw data with the endpoint of the sender.
@@ -746,8 +779,12 @@
   void async_receive_from(const MutableBufferSequence& buffers,
       endpoint_type& sender_endpoint, ReadHandler handler)
   {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
     this->service.async_receive_from(this->implementation, buffers,
- sender_endpoint, 0, handler);
+ sender_endpoint, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 
   /// Start an asynchronous receive.
@@ -784,8 +821,12 @@
       endpoint_type& sender_endpoint, socket_base::message_flags flags,
       ReadHandler handler)
   {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
     this->service.async_receive_from(this->implementation, buffers,
- sender_endpoint, flags, handler);
+ sender_endpoint, flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 };
 

Added: trunk/boost/asio/basic_seq_packet_socket.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/asio/basic_seq_packet_socket.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -0,0 +1,473 @@
+//
+// basic_seq_packet_socket.hpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// 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)
+//
+
+#ifndef BOOST_ASIO_BASIC_SEQ_PACKET_SOCKET_HPP
+#define BOOST_ASIO_BASIC_SEQ_PACKET_SOCKET_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
+
+#include <boost/asio/detail/config.hpp>
+#include <cstddef>
+#include <boost/asio/basic_socket.hpp>
+#include <boost/asio/detail/handler_type_requirements.hpp>
+#include <boost/asio/detail/throw_error.hpp>
+#include <boost/asio/error.hpp>
+#include <boost/asio/seq_packet_socket_service.hpp>
+
+#include <boost/asio/detail/push_options.hpp>
+
+namespace boost {
+namespace asio {
+
+/// Provides sequenced packet socket functionality.
+/**
+ * The basic_seq_packet_socket class template provides asynchronous and blocking
+ * sequenced packet socket functionality.
+ *
+ * @par Thread Safety
+ * @e Distinct @e objects: Safe._at_n
+ * @e Shared @e objects: Unsafe.
+ */
+template <typename Protocol,
+ typename SeqPacketSocketService = seq_packet_socket_service<Protocol> >
+class basic_seq_packet_socket
+ : public basic_socket<Protocol, SeqPacketSocketService>
+{
+public:
+ /// (Deprecated: Use native_handle_type.) The native representation of a
+ /// socket.
+ typedef typename SeqPacketSocketService::native_handle_type native_type;
+
+ /// The native representation of a socket.
+ typedef typename SeqPacketSocketService::native_handle_type
+ native_handle_type;
+
+ /// The protocol type.
+ typedef Protocol protocol_type;
+
+ /// The endpoint type.
+ typedef typename Protocol::endpoint endpoint_type;
+
+ /// Construct a basic_seq_packet_socket without opening it.
+ /**
+ * This constructor creates a sequenced packet socket without opening it. The
+ * socket needs to be opened and then connected or accepted before data can
+ * be sent or received on it.
+ *
+ * @param io_service The io_service object that the sequenced packet socket
+ * will use to dispatch handlers for any asynchronous operations performed on
+ * the socket.
+ */
+ explicit basic_seq_packet_socket(boost::asio::io_service& io_service)
+ : basic_socket<Protocol, SeqPacketSocketService>(io_service)
+ {
+ }
+
+ /// Construct and open a basic_seq_packet_socket.
+ /**
+ * This constructor creates and opens a sequenced_packet socket. The socket
+ * needs to be connected or accepted before data can be sent or received on
+ * it.
+ *
+ * @param io_service The io_service object that the sequenced packet socket
+ * will use to dispatch handlers for any asynchronous operations performed on
+ * the socket.
+ *
+ * @param protocol An object specifying protocol parameters to be used.
+ *
+ * @throws boost::system::system_error Thrown on failure.
+ */
+ basic_seq_packet_socket(boost::asio::io_service& io_service,
+ const protocol_type& protocol)
+ : basic_socket<Protocol, SeqPacketSocketService>(io_service, protocol)
+ {
+ }
+
+ /// Construct a basic_seq_packet_socket, opening it and binding it to the
+ /// given local endpoint.
+ /**
+ * This constructor creates a sequenced packet socket and automatically opens
+ * it bound to the specified endpoint on the local machine. The protocol used
+ * is the protocol associated with the given endpoint.
+ *
+ * @param io_service The io_service object that the sequenced packet socket
+ * will use to dispatch handlers for any asynchronous operations performed on
+ * the socket.
+ *
+ * @param endpoint An endpoint on the local machine to which the sequenced
+ * packet socket will be bound.
+ *
+ * @throws boost::system::system_error Thrown on failure.
+ */
+ basic_seq_packet_socket(boost::asio::io_service& io_service,
+ const endpoint_type& endpoint)
+ : basic_socket<Protocol, SeqPacketSocketService>(io_service, endpoint)
+ {
+ }
+
+ /// Construct a basic_seq_packet_socket on an existing native socket.
+ /**
+ * This constructor creates a sequenced packet socket object to hold an
+ * existing native socket.
+ *
+ * @param io_service The io_service object that the sequenced packet socket
+ * will use to dispatch handlers for any asynchronous operations performed on
+ * the socket.
+ *
+ * @param protocol An object specifying protocol parameters to be used.
+ *
+ * @param native_socket The new underlying socket implementation.
+ *
+ * @throws boost::system::system_error Thrown on failure.
+ */
+ basic_seq_packet_socket(boost::asio::io_service& io_service,
+ const protocol_type& protocol, const native_handle_type& native_socket)
+ : basic_socket<Protocol, SeqPacketSocketService>(
+ io_service, protocol, native_socket)
+ {
+ }
+
+ /// Send some data on the socket.
+ /**
+ * This function is used to send data on the sequenced packet socket. The
+ * function call will block until the data has been sent successfully, or an
+ * until error occurs.
+ *
+ * @param buffers One or more data buffers to be sent on the socket.
+ *
+ * @param flags Flags specifying how the send call is to be made.
+ *
+ * @returns The number of bytes sent.
+ *
+ * @throws boost::system::system_error Thrown on failure.
+ *
+ * @par Example
+ * To send a single data buffer use the @ref buffer function as follows:
+ * @code
+ * socket.send(boost::asio::buffer(data, size), 0);
+ * @endcode
+ * See the @ref buffer documentation for information on sending multiple
+ * buffers in one go, and how to use it with arrays, boost::array or
+ * std::vector.
+ */
+ template <typename ConstBufferSequence>
+ std::size_t send(const ConstBufferSequence& buffers,
+ socket_base::message_flags flags)
+ {
+ boost::system::error_code ec;
+ std::size_t s = this->service.send(
+ this->implementation, buffers, flags, ec);
+ boost::asio::detail::throw_error(ec);
+ return s;
+ }
+
+ /// Send some data on the socket.
+ /**
+ * This function is used to send data on the sequenced packet socket. The
+ * function call will block the data has been sent successfully, or an until
+ * error occurs.
+ *
+ * @param buffers One or more data buffers to be sent on the socket.
+ *
+ * @param flags Flags specifying how the send call is to be made.
+ *
+ * @param ec Set to indicate what error occurred, if any.
+ *
+ * @returns The number of bytes sent. Returns 0 if an error occurred.
+ *
+ * @note The send operation may not transmit all of the data to the peer.
+ * Consider using the @ref write function if you need to ensure that all data
+ * is written before the blocking operation completes.
+ */
+ template <typename ConstBufferSequence>
+ std::size_t send(const ConstBufferSequence& buffers,
+ socket_base::message_flags flags, boost::system::error_code& ec)
+ {
+ return this->service.send(this->implementation, buffers, flags, ec);
+ }
+
+ /// Start an asynchronous send.
+ /**
+ * This function is used to asynchronously send data on the sequenced packet
+ * socket. The function call always returns immediately.
+ *
+ * @param buffers One or more data buffers to be sent on the socket. Although
+ * the buffers object may be copied as necessary, ownership of the underlying
+ * memory blocks is retained by the caller, which must guarantee that they
+ * remain valid until the handler is called.
+ *
+ * @param flags Flags specifying how the send call is to be made.
+ *
+ * @param handler The handler to be called when the send operation completes.
+ * Copies will be made of the handler as required. The function signature of
+ * the handler must be:
+ * @code void handler(
+ * const boost::system::error_code& error, // Result of operation.
+ * std::size_t bytes_transferred // Number of bytes sent.
+ * ); @endcode
+ * Regardless of whether the asynchronous operation completes immediately or
+ * not, the handler will not be invoked from within this function. Invocation
+ * of the handler will be performed in a manner equivalent to using
+ * boost::asio::io_service::post().
+ *
+ * @par Example
+ * To send a single data buffer use the @ref buffer function as follows:
+ * @code
+ * socket.async_send(boost::asio::buffer(data, size), 0, handler);
+ * @endcode
+ * See the @ref buffer documentation for information on sending multiple
+ * buffers in one go, and how to use it with arrays, boost::array or
+ * std::vector.
+ */
+ template <typename ConstBufferSequence, typename WriteHandler>
+ void async_send(const ConstBufferSequence& buffers,
+ socket_base::message_flags flags, WriteHandler handler)
+ {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a WriteHandler.
+ BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
+
+ this->service.async_send(this->implementation, buffers, flags,
+ BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
+ }
+
+ /// Receive some data on the socket.
+ /**
+ * This function is used to receive data on the sequenced packet socket. The
+ * function call will block until data has been received successfully, or
+ * until an error occurs.
+ *
+ * @param buffers One or more buffers into which the data will be received.
+ *
+ * @param out_flags After the receive call completes, contains flags
+ * associated with the received data. For example, if the
+ * socket_base::message_end_of_record bit is set then the received data marks
+ * the end of a record.
+ *
+ * @returns The number of bytes received.
+ *
+ * @throws boost::system::system_error Thrown on failure. An error code of
+ * boost::asio::error::eof indicates that the connection was closed by the
+ * peer.
+ *
+ * @par Example
+ * To receive into a single data buffer use the @ref buffer function as
+ * follows:
+ * @code
+ * socket.receive(boost::asio::buffer(data, size), out_flags);
+ * @endcode
+ * See the @ref buffer documentation for information on receiving into
+ * multiple buffers in one go, and how to use it with arrays, boost::array or
+ * std::vector.
+ */
+ template <typename MutableBufferSequence>
+ std::size_t receive(const MutableBufferSequence& buffers,
+ socket_base::message_flags& out_flags)
+ {
+ boost::system::error_code ec;
+ std::size_t s = this->service.receive(
+ this->implementation, buffers, 0, out_flags, ec);
+ boost::asio::detail::throw_error(ec);
+ return s;
+ }
+
+ /// Receive some data on the socket.
+ /**
+ * This function is used to receive data on the sequenced packet socket. The
+ * function call will block until data has been received successfully, or
+ * until an error occurs.
+ *
+ * @param buffers One or more buffers into which the data will be received.
+ *
+ * @param in_flags Flags specifying how the receive call is to be made.
+ *
+ * @param out_flags After the receive call completes, contains flags
+ * associated with the received data. For example, if the
+ * socket_base::message_end_of_record bit is set then the received data marks
+ * the end of a record.
+ *
+ * @returns The number of bytes received.
+ *
+ * @throws boost::system::system_error Thrown on failure. An error code of
+ * boost::asio::error::eof indicates that the connection was closed by the
+ * peer.
+ *
+ * @note The receive operation may not receive all of the requested number of
+ * bytes. Consider using the @ref read function if you need to ensure that the
+ * requested amount of data is read before the blocking operation completes.
+ *
+ * @par Example
+ * To receive into a single data buffer use the @ref buffer function as
+ * follows:
+ * @code
+ * socket.receive(boost::asio::buffer(data, size), 0, out_flags);
+ * @endcode
+ * See the @ref buffer documentation for information on receiving into
+ * multiple buffers in one go, and how to use it with arrays, boost::array or
+ * std::vector.
+ */
+ template <typename MutableBufferSequence>
+ std::size_t receive(const MutableBufferSequence& buffers,
+ socket_base::message_flags in_flags,
+ socket_base::message_flags& out_flags)
+ {
+ boost::system::error_code ec;
+ std::size_t s = this->service.receive(
+ this->implementation, buffers, in_flags, out_flags, ec);
+ boost::asio::detail::throw_error(ec);
+ return s;
+ }
+
+ /// Receive some data on a connected socket.
+ /**
+ * This function is used to receive data on the sequenced packet socket. The
+ * function call will block until data has been received successfully, or
+ * until an error occurs.
+ *
+ * @param buffers One or more buffers into which the data will be received.
+ *
+ * @param in_flags Flags specifying how the receive call is to be made.
+ *
+ * @param out_flags After the receive call completes, contains flags
+ * associated with the received data. For example, if the
+ * socket_base::message_end_of_record bit is set then the received data marks
+ * the end of a record.
+ *
+ * @param ec Set to indicate what error occurred, if any.
+ *
+ * @returns The number of bytes received. Returns 0 if an error occurred.
+ *
+ * @note The receive operation may not receive all of the requested number of
+ * bytes. Consider using the @ref read function if you need to ensure that the
+ * requested amount of data is read before the blocking operation completes.
+ */
+ template <typename MutableBufferSequence>
+ std::size_t receive(const MutableBufferSequence& buffers,
+ socket_base::message_flags in_flags,
+ socket_base::message_flags& out_flags, boost::system::error_code& ec)
+ {
+ return this->service.receive(this->implementation,
+ buffers, in_flags, out_flags, ec);
+ }
+
+ /// Start an asynchronous receive.
+ /**
+ * This function is used to asynchronously receive data from the sequenced
+ * packet socket. The function call always returns immediately.
+ *
+ * @param buffers One or more buffers into which the data will be received.
+ * Although the buffers object may be copied as necessary, ownership of the
+ * underlying memory blocks is retained by the caller, which must guarantee
+ * that they remain valid until the handler is called.
+ *
+ * @param out_flags Once the asynchronous operation completes, contains flags
+ * associated with the received data. For example, if the
+ * socket_base::message_end_of_record bit is set then the received data marks
+ * the end of a record. The caller must guarantee that the referenced
+ * variable remains valid until the handler is called.
+ *
+ * @param handler The handler to be called when the receive operation
+ * completes. Copies will be made of the handler as required. The function
+ * signature of the handler must be:
+ * @code void handler(
+ * const boost::system::error_code& error, // Result of operation.
+ * std::size_t bytes_transferred // Number of bytes received.
+ * ); @endcode
+ * Regardless of whether the asynchronous operation completes immediately or
+ * not, the handler will not be invoked from within this function. Invocation
+ * of the handler will be performed in a manner equivalent to using
+ * boost::asio::io_service::post().
+ *
+ * @par Example
+ * To receive into a single data buffer use the @ref buffer function as
+ * follows:
+ * @code
+ * socket.async_receive(boost::asio::buffer(data, size), out_flags, handler);
+ * @endcode
+ * See the @ref buffer documentation for information on receiving into
+ * multiple buffers in one go, and how to use it with arrays, boost::array or
+ * std::vector.
+ */
+ template <typename MutableBufferSequence, typename ReadHandler>
+ void async_receive(const MutableBufferSequence& buffers,
+ socket_base::message_flags& out_flags, ReadHandler handler)
+ {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
+ this->service.async_receive(this->implementation, buffers,
+ 0, out_flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+ }
+
+ /// Start an asynchronous receive.
+ /**
+ * This function is used to asynchronously receive data from the sequenced
+ * data socket. The function call always returns immediately.
+ *
+ * @param buffers One or more buffers into which the data will be received.
+ * Although the buffers object may be copied as necessary, ownership of the
+ * underlying memory blocks is retained by the caller, which must guarantee
+ * that they remain valid until the handler is called.
+ *
+ * @param in_flags Flags specifying how the receive call is to be made.
+ *
+ * @param out_flags Once the asynchronous operation completes, contains flags
+ * associated with the received data. For example, if the
+ * socket_base::message_end_of_record bit is set then the received data marks
+ * the end of a record. The caller must guarantee that the referenced
+ * variable remains valid until the handler is called.
+ *
+ * @param handler The handler to be called when the receive operation
+ * completes. Copies will be made of the handler as required. The function
+ * signature of the handler must be:
+ * @code void handler(
+ * const boost::system::error_code& error, // Result of operation.
+ * std::size_t bytes_transferred // Number of bytes received.
+ * ); @endcode
+ * Regardless of whether the asynchronous operation completes immediately or
+ * not, the handler will not be invoked from within this function. Invocation
+ * of the handler will be performed in a manner equivalent to using
+ * boost::asio::io_service::post().
+ *
+ * @par Example
+ * To receive into a single data buffer use the @ref buffer function as
+ * follows:
+ * @code
+ * socket.async_receive(
+ * boost::asio::buffer(data, size),
+ * 0, out_flags, handler);
+ * @endcode
+ * See the @ref buffer documentation for information on receiving into
+ * multiple buffers in one go, and how to use it with arrays, boost::array or
+ * std::vector.
+ */
+ template <typename MutableBufferSequence, typename ReadHandler>
+ void async_receive(const MutableBufferSequence& buffers,
+ socket_base::message_flags in_flags,
+ socket_base::message_flags& out_flags, ReadHandler handler)
+ {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
+ this->service.async_receive(this->implementation, buffers,
+ in_flags, out_flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+ }
+};
+
+} // namespace asio
+} // namespace boost
+
+#include <boost/asio/detail/pop_options.hpp>
+
+#endif // BOOST_ASIO_BASIC_SEQ_PACKET_SOCKET_HPP

Modified: trunk/boost/asio/basic_serial_port.hpp
==============================================================================
--- trunk/boost/asio/basic_serial_port.hpp (original)
+++ trunk/boost/asio/basic_serial_port.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -23,6 +23,7 @@
 
 #include <string>
 #include <boost/asio/basic_io_object.hpp>
+#include <boost/asio/detail/handler_type_requirements.hpp>
 #include <boost/asio/detail/throw_error.hpp>
 #include <boost/asio/error.hpp>
 #include <boost/asio/serial_port_base.hpp>
@@ -48,8 +49,12 @@
     public serial_port_base
 {
 public:
+ /// (Deprecated: Use native_handle_type.) The native representation of a
+ /// serial port.
+ typedef typename SerialPortService::native_handle_type native_type;
+
   /// The native representation of a serial port.
- typedef typename SerialPortService::native_type native_type;
+ typedef typename SerialPortService::native_handle_type native_handle_type;
 
   /// A basic_serial_port is always the lowest layer.
   typedef basic_serial_port<SerialPortService> lowest_layer_type;
@@ -119,7 +124,7 @@
    * @throws boost::system::system_error Thrown on failure.
    */
   basic_serial_port(boost::asio::io_service& io_service,
- const native_type& native_serial_port)
+ const native_handle_type& native_serial_port)
     : basic_io_object<SerialPortService>(io_service)
   {
     boost::system::error_code ec;
@@ -193,7 +198,7 @@
    *
    * @throws boost::system::system_error Thrown on failure.
    */
- void assign(const native_type& native_serial_port)
+ void assign(const native_handle_type& native_serial_port)
   {
     boost::system::error_code ec;
     this->service.assign(this->implementation, native_serial_port, ec);
@@ -208,7 +213,7 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
- boost::system::error_code assign(const native_type& native_serial_port,
+ boost::system::error_code assign(const native_handle_type& native_serial_port,
       boost::system::error_code& ec)
   {
     return this->service.assign(this->implementation, native_serial_port, ec);
@@ -248,7 +253,8 @@
     return this->service.close(this->implementation, ec);
   }
 
- /// Get the native serial port representation.
+ /// (Deprecated: Use native_handle().) Get the native serial port
+ /// representation.
   /**
    * This function may be used to obtain the underlying representation of the
    * serial port. This is intended to allow access to native serial port
@@ -256,7 +262,18 @@
    */
   native_type native()
   {
- return this->service.native(this->implementation);
+ return this->service.native_handle(this->implementation);
+ }
+
+ /// Get the native serial port representation.
+ /**
+ * This function may be used to obtain the underlying representation of the
+ * serial port. This is intended to allow access to native serial port
+ * functionality that is not otherwise provided.
+ */
+ native_handle_type native_handle()
+ {
+ return this->service.native_handle(this->implementation);
   }
 
   /// Cancel all asynchronous operations associated with the serial port.
@@ -503,7 +520,12 @@
   void async_write_some(const ConstBufferSequence& buffers,
       WriteHandler handler)
   {
- this->service.async_write_some(this->implementation, buffers, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a WriteHandler.
+ BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
+
+ this->service.async_write_some(this->implementation, buffers,
+ BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
   /// Read some data from the serial port.
@@ -607,7 +629,12 @@
   void async_read_some(const MutableBufferSequence& buffers,
       ReadHandler handler)
   {
- this->service.async_read_some(this->implementation, buffers, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
+ this->service.async_read_some(this->implementation, buffers,
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 };
 

Modified: trunk/boost/asio/basic_socket.hpp
==============================================================================
--- trunk/boost/asio/basic_socket.hpp (original)
+++ trunk/boost/asio/basic_socket.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -17,6 +17,7 @@
 
 #include <boost/asio/detail/config.hpp>
 #include <boost/asio/basic_io_object.hpp>
+#include <boost/asio/detail/handler_type_requirements.hpp>
 #include <boost/asio/detail/throw_error.hpp>
 #include <boost/asio/error.hpp>
 #include <boost/asio/socket_base.hpp>
@@ -41,8 +42,12 @@
     public socket_base
 {
 public:
+ /// (Deprecated: Use native_handle_type.) The native representation of a
+ /// socket.
+ typedef typename SocketService::native_handle_type native_type;
+
   /// The native representation of a socket.
- typedef typename SocketService::native_type native_type;
+ typedef typename SocketService::native_handle_type native_handle_type;
 
   /// The protocol type.
   typedef Protocol protocol_type;
@@ -125,7 +130,7 @@
    * @throws boost::system::system_error Thrown on failure.
    */
   basic_socket(boost::asio::io_service& io_service,
- const protocol_type& protocol, const native_type& native_socket)
+ const protocol_type& protocol, const native_handle_type& native_socket)
     : basic_io_object<SocketService>(io_service)
   {
     boost::system::error_code ec;
@@ -217,7 +222,8 @@
    *
    * @throws boost::system::system_error Thrown on failure.
    */
- void assign(const protocol_type& protocol, const native_type& native_socket)
+ void assign(const protocol_type& protocol,
+ const native_handle_type& native_socket)
   {
     boost::system::error_code ec;
     this->service.assign(this->implementation, protocol, native_socket, ec);
@@ -235,7 +241,7 @@
    * @param ec Set to indicate what error occurred, if any.
    */
   boost::system::error_code assign(const protocol_type& protocol,
- const native_type& native_socket, boost::system::error_code& ec)
+ const native_handle_type& native_socket, boost::system::error_code& ec)
   {
     return this->service.assign(this->implementation,
         protocol, native_socket, ec);
@@ -293,7 +299,7 @@
     return this->service.close(this->implementation, ec);
   }
 
- /// Get the native socket representation.
+ /// (Deprecated: Use native_handle().) Get the native socket representation.
   /**
    * This function may be used to obtain the underlying representation of the
    * socket. This is intended to allow access to native socket functionality
@@ -301,7 +307,18 @@
    */
   native_type native()
   {
- return this->service.native(this->implementation);
+ return this->service.native_handle(this->implementation);
+ }
+
+ /// Get the native socket representation.
+ /**
+ * This function may be used to obtain the underlying representation of the
+ * socket. This is intended to allow access to native socket functionality
+ * that is not otherwise provided.
+ */
+ native_handle_type native_handle()
+ {
+ return this->service.native_handle(this->implementation);
   }
 
   /// Cancel all asynchronous operations associated with the socket.
@@ -640,6 +657,10 @@
   template <typename ConnectHandler>
   void async_connect(const endpoint_type& peer_endpoint, ConnectHandler handler)
   {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ConnectHandler.
+ BOOST_ASIO_CONNECT_HANDLER_CHECK(ConnectHandler, handler) type_check;
+
     if (!is_open())
     {
       boost::system::error_code ec;
@@ -652,7 +673,8 @@
       }
     }
 
- this->service.async_connect(this->implementation, peer_endpoint, handler);
+ this->service.async_connect(this->implementation, peer_endpoint,
+ BOOST_ASIO_MOVE_CAST(ConnectHandler)(handler));
   }
 
   /// Set an option on the socket.
@@ -897,6 +919,333 @@
     return this->service.io_control(this->implementation, command, ec);
   }
 
+ /// Gets the non-blocking mode of the socket.
+ /**
+ * @returns @c true if the socket's synchronous operations will fail with
+ * boost::asio::error::would_block if they are unable to perform the requested
+ * operation immediately. If @c false, synchronous operations will block
+ * until complete.
+ *
+ * @note The non-blocking mode has no effect on the behaviour of asynchronous
+ * operations. Asynchronous operations will never fail with the error
+ * boost::asio::error::would_block.
+ */
+ bool non_blocking() const
+ {
+ return this->service.non_blocking(this->implementation);
+ }
+
+ /// Sets the non-blocking mode of the socket.
+ /**
+ * @param mode If @c true, the socket's synchronous operations will fail with
+ * boost::asio::error::would_block if they are unable to perform the requested
+ * operation immediately. If @c false, synchronous operations will block
+ * until complete.
+ *
+ * @throws boost::system::system_error Thrown on failure.
+ *
+ * @note The non-blocking mode has no effect on the behaviour of asynchronous
+ * operations. Asynchronous operations will never fail with the error
+ * boost::asio::error::would_block.
+ */
+ void non_blocking(bool mode)
+ {
+ boost::system::error_code ec;
+ this->service.non_blocking(this->implementation, mode, ec);
+ boost::asio::detail::throw_error(ec);
+ }
+
+ /// Sets the non-blocking mode of the socket.
+ /**
+ * @param mode If @c true, the socket's synchronous operations will fail with
+ * boost::asio::error::would_block if they are unable to perform the requested
+ * operation immediately. If @c false, synchronous operations will block
+ * until complete.
+ *
+ * @param ec Set to indicate what error occurred, if any.
+ *
+ * @note The non-blocking mode has no effect on the behaviour of asynchronous
+ * operations. Asynchronous operations will never fail with the error
+ * boost::asio::error::would_block.
+ */
+ boost::system::error_code non_blocking(
+ bool mode, boost::system::error_code& ec)
+ {
+ return this->service.non_blocking(this->implementation, mode, ec);
+ }
+
+ /// Gets the non-blocking mode of the native socket implementation.
+ /**
+ * This function is used to retrieve the non-blocking mode of the underlying
+ * native socket. This mode has no effect on the behaviour of the socket
+ * object's synchronous operations.
+ *
+ * @returns @c true if the underlying socket is in non-blocking mode and
+ * direct system calls may fail with boost::asio::error::would_block (or the
+ * equivalent system error).
+ *
+ * @note The current non-blocking mode is cached by the socket object.
+ * Consequently, the return value may be incorrect if the non-blocking mode
+ * was set directly on the native socket.
+ *
+ * @par Example
+ * This function is 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 following example
+ * illustrates how Linux's @c sendfile system call might be encapsulated:
+ * @code template <typename Handler>
+ * struct sendfile_op
+ * {
+ * tcp::socket& sock_;
+ * int fd_;
+ * Handler handler_;
+ * off_t offset_;
+ * std::size_t total_bytes_transferred_;
+ *
+ * // Function call operator meeting WriteHandler requirements.
+ * // Used as the handler for the async_write_some operation.
+ * void operator()(boost::system::error_code ec, std::size_t)
+ * {
+ * // Put the underlying socket into non-blocking mode.
+ * if (!ec)
+ * if (!sock_.native_non_blocking())
+ * sock_.native_non_blocking(true, ec);
+ *
+ * if (!ec)
+ * {
+ * for (;;)
+ * {
+ * // Try the system call.
+ * errno = 0;
+ * int n = ::sendfile(sock_.native_handle(), fd_, &offset_, 65536);
+ * ec = boost::system::error_code(n < 0 ? errno : 0,
+ * boost::asio::error::get_system_category());
+ * total_bytes_transferred_ += ec ? 0 : n;
+ *
+ * // Retry operation immediately if interrupted by signal.
+ * if (ec == boost::asio::error::interrupted)
+ * continue;
+ *
+ * // Check if we need to run the operation again.
+ * if (ec == boost::asio::error::would_block
+ * || ec == boost::asio::error::try_again)
+ * {
+ * // We have to wait for the socket to become ready again.
+ * sock_.async_write_some(boost::asio::null_buffers(), *this);
+ * return;
+ * }
+ *
+ * if (ec || n == 0)
+ * {
+ * // An error occurred, or we have reached the end of the file.
+ * // Either way we must exit the loop so we can call the handler.
+ * break;
+ * }
+ *
+ * // Loop around to try calling sendfile again.
+ * }
+ * }
+ *
+ * // Pass result back to user's handler.
+ * handler_(ec, total_bytes_transferred_);
+ * }
+ * };
+ *
+ * template <typename Handler>
+ * void async_sendfile(tcp::socket& sock, int fd, Handler h)
+ * {
+ * sendfile_op<Handler> op = { sock, fd, h, 0, 0 };
+ * sock.async_write_some(boost::asio::null_buffers(), op);
+ * } @endcode
+ */
+ bool native_non_blocking() const
+ {
+ return this->service.native_non_blocking(this->implementation);
+ }
+
+ /// Sets the non-blocking mode of the native socket implementation.
+ /**
+ * This function is used to modify the non-blocking mode of the underlying
+ * native socket. It has no effect on the behaviour of the socket object's
+ * synchronous operations.
+ *
+ * @param mode If @c true, the underlying socket is put into non-blocking
+ * mode and direct system calls may fail with boost::asio::error::would_block
+ * (or the equivalent system error).
+ *
+ * @throws boost::system::system_error Thrown on failure. If the @c mode is
+ * @c false, but the current value of @c non_blocking() is @c true, this
+ * function fails with boost::asio::error::invalid_argument, as the
+ * combination does not make sense.
+ *
+ * @par Example
+ * This function is 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 following example
+ * illustrates how Linux's @c sendfile system call might be encapsulated:
+ * @code template <typename Handler>
+ * struct sendfile_op
+ * {
+ * tcp::socket& sock_;
+ * int fd_;
+ * Handler handler_;
+ * off_t offset_;
+ * std::size_t total_bytes_transferred_;
+ *
+ * // Function call operator meeting WriteHandler requirements.
+ * // Used as the handler for the async_write_some operation.
+ * void operator()(boost::system::error_code ec, std::size_t)
+ * {
+ * // Put the underlying socket into non-blocking mode.
+ * if (!ec)
+ * if (!sock_.native_non_blocking())
+ * sock_.native_non_blocking(true, ec);
+ *
+ * if (!ec)
+ * {
+ * for (;;)
+ * {
+ * // Try the system call.
+ * errno = 0;
+ * int n = ::sendfile(sock_.native_handle(), fd_, &offset_, 65536);
+ * ec = boost::system::error_code(n < 0 ? errno : 0,
+ * boost::asio::error::get_system_category());
+ * total_bytes_transferred_ += ec ? 0 : n;
+ *
+ * // Retry operation immediately if interrupted by signal.
+ * if (ec == boost::asio::error::interrupted)
+ * continue;
+ *
+ * // Check if we need to run the operation again.
+ * if (ec == boost::asio::error::would_block
+ * || ec == boost::asio::error::try_again)
+ * {
+ * // We have to wait for the socket to become ready again.
+ * sock_.async_write_some(boost::asio::null_buffers(), *this);
+ * return;
+ * }
+ *
+ * if (ec || n == 0)
+ * {
+ * // An error occurred, or we have reached the end of the file.
+ * // Either way we must exit the loop so we can call the handler.
+ * break;
+ * }
+ *
+ * // Loop around to try calling sendfile again.
+ * }
+ * }
+ *
+ * // Pass result back to user's handler.
+ * handler_(ec, total_bytes_transferred_);
+ * }
+ * };
+ *
+ * template <typename Handler>
+ * void async_sendfile(tcp::socket& sock, int fd, Handler h)
+ * {
+ * sendfile_op<Handler> op = { sock, fd, h, 0, 0 };
+ * sock.async_write_some(boost::asio::null_buffers(), op);
+ * } @endcode
+ */
+ void native_non_blocking(bool mode)
+ {
+ boost::system::error_code ec;
+ this->service.native_non_blocking(this->implementation, mode, ec);
+ boost::asio::detail::throw_error(ec);
+ }
+
+ /// Sets the non-blocking mode of the native socket implementation.
+ /**
+ * This function is used to modify the non-blocking mode of the underlying
+ * native socket. It has no effect on the behaviour of the socket object's
+ * synchronous operations.
+ *
+ * @param mode If @c true, the underlying socket is put into non-blocking
+ * mode and direct system calls may fail with boost::asio::error::would_block
+ * (or the equivalent system error).
+ *
+ * @param ec Set to indicate what error occurred, if any. If the @c mode is
+ * @c false, but the current value of @c non_blocking() is @c true, this
+ * function fails with boost::asio::error::invalid_argument, as the
+ * combination does not make sense.
+ *
+ * @par Example
+ * This function is 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 following example
+ * illustrates how Linux's @c sendfile system call might be encapsulated:
+ * @code template <typename Handler>
+ * struct sendfile_op
+ * {
+ * tcp::socket& sock_;
+ * int fd_;
+ * Handler handler_;
+ * off_t offset_;
+ * std::size_t total_bytes_transferred_;
+ *
+ * // Function call operator meeting WriteHandler requirements.
+ * // Used as the handler for the async_write_some operation.
+ * void operator()(boost::system::error_code ec, std::size_t)
+ * {
+ * // Put the underlying socket into non-blocking mode.
+ * if (!ec)
+ * if (!sock_.native_non_blocking())
+ * sock_.native_non_blocking(true, ec);
+ *
+ * if (!ec)
+ * {
+ * for (;;)
+ * {
+ * // Try the system call.
+ * errno = 0;
+ * int n = ::sendfile(sock_.native_handle(), fd_, &offset_, 65536);
+ * ec = boost::system::error_code(n < 0 ? errno : 0,
+ * boost::asio::error::get_system_category());
+ * total_bytes_transferred_ += ec ? 0 : n;
+ *
+ * // Retry operation immediately if interrupted by signal.
+ * if (ec == boost::asio::error::interrupted)
+ * continue;
+ *
+ * // Check if we need to run the operation again.
+ * if (ec == boost::asio::error::would_block
+ * || ec == boost::asio::error::try_again)
+ * {
+ * // We have to wait for the socket to become ready again.
+ * sock_.async_write_some(boost::asio::null_buffers(), *this);
+ * return;
+ * }
+ *
+ * if (ec || n == 0)
+ * {
+ * // An error occurred, or we have reached the end of the file.
+ * // Either way we must exit the loop so we can call the handler.
+ * break;
+ * }
+ *
+ * // Loop around to try calling sendfile again.
+ * }
+ * }
+ *
+ * // Pass result back to user's handler.
+ * handler_(ec, total_bytes_transferred_);
+ * }
+ * };
+ *
+ * template <typename Handler>
+ * void async_sendfile(tcp::socket& sock, int fd, Handler h)
+ * {
+ * sendfile_op<Handler> op = { sock, fd, h, 0, 0 };
+ * sock.async_write_some(boost::asio::null_buffers(), op);
+ * } @endcode
+ */
+ boost::system::error_code native_non_blocking(
+ bool mode, boost::system::error_code& ec)
+ {
+ return this->service.native_non_blocking(this->implementation, mode, ec);
+ }
+
   /// Get the local endpoint of the socket.
   /**
    * This function is used to obtain the locally bound endpoint of the socket.

Modified: trunk/boost/asio/basic_socket_acceptor.hpp
==============================================================================
--- trunk/boost/asio/basic_socket_acceptor.hpp (original)
+++ trunk/boost/asio/basic_socket_acceptor.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -18,6 +18,7 @@
 #include <boost/asio/detail/config.hpp>
 #include <boost/asio/basic_io_object.hpp>
 #include <boost/asio/basic_socket.hpp>
+#include <boost/asio/detail/handler_type_requirements.hpp>
 #include <boost/asio/detail/throw_error.hpp>
 #include <boost/asio/error.hpp>
 #include <boost/asio/socket_acceptor_service.hpp>
@@ -55,8 +56,12 @@
     public socket_base
 {
 public:
+ /// (Deprecated: Use native_handle_type.) The native representation of an
+ /// acceptor.
+ typedef typename SocketAcceptorService::native_handle_type native_type;
+
   /// The native representation of an acceptor.
- typedef typename SocketAcceptorService::native_type native_type;
+ typedef typename SocketAcceptorService::native_handle_type native_handle_type;
 
   /// The protocol type.
   typedef Protocol protocol_type;
@@ -163,7 +168,7 @@
    * @throws boost::system::system_error Thrown on failure.
    */
   basic_socket_acceptor(boost::asio::io_service& io_service,
- const protocol_type& protocol, const native_type& native_acceptor)
+ const protocol_type& protocol, const native_handle_type& native_acceptor)
     : basic_io_object<SocketAcceptorService>(io_service)
   {
     boost::system::error_code ec;
@@ -229,7 +234,8 @@
    *
    * @throws boost::system::system_error Thrown on failure.
    */
- void assign(const protocol_type& protocol, const native_type& native_acceptor)
+ void assign(const protocol_type& protocol,
+ const native_handle_type& native_acceptor)
   {
     boost::system::error_code ec;
     this->service.assign(this->implementation, protocol, native_acceptor, ec);
@@ -247,7 +253,7 @@
    * @param ec Set to indicate what error occurred, if any.
    */
   boost::system::error_code assign(const protocol_type& protocol,
- const native_type& native_acceptor, boost::system::error_code& ec)
+ const native_handle_type& native_acceptor, boost::system::error_code& ec)
   {
     return this->service.assign(this->implementation,
         protocol, native_acceptor, ec);
@@ -399,7 +405,7 @@
     return this->service.close(this->implementation, ec);
   }
 
- /// Get the native acceptor representation.
+ /// (Deprecated: Use native_handle().) Get the native acceptor representation.
   /**
    * This function may be used to obtain the underlying representation of the
    * acceptor. This is intended to allow access to native acceptor functionality
@@ -407,7 +413,18 @@
    */
   native_type native()
   {
- return this->service.native(this->implementation);
+ return this->service.native_handle(this->implementation);
+ }
+
+ /// Get the native acceptor representation.
+ /**
+ * This function may be used to obtain the underlying representation of the
+ * acceptor. This is intended to allow access to native acceptor functionality
+ * that is not otherwise provided.
+ */
+ native_handle_type native_handle()
+ {
+ return this->service.native_handle(this->implementation);
   }
 
   /// Cancel all asynchronous operations associated with the acceptor.
@@ -564,6 +581,183 @@
     return this->service.get_option(this->implementation, option, ec);
   }
 
+ /// Perform an IO control command on the acceptor.
+ /**
+ * This function is used to execute an IO control command on the acceptor.
+ *
+ * @param command The IO control command to be performed on the acceptor.
+ *
+ * @throws boost::system::system_error Thrown on failure.
+ *
+ * @sa IoControlCommand @n
+ * boost::asio::socket_base::non_blocking_io
+ *
+ * @par Example
+ * Getting the number of bytes ready to read:
+ * @code
+ * boost::asio::ip::tcp::acceptor acceptor(io_service);
+ * ...
+ * boost::asio::ip::tcp::acceptor::non_blocking_io command(true);
+ * socket.io_control(command);
+ * @endcode
+ */
+ template <typename IoControlCommand>
+ void io_control(IoControlCommand& command)
+ {
+ boost::system::error_code ec;
+ this->service.io_control(this->implementation, command, ec);
+ boost::asio::detail::throw_error(ec);
+ }
+
+ /// Perform an IO control command on the acceptor.
+ /**
+ * This function is used to execute an IO control command on the acceptor.
+ *
+ * @param command The IO control command to be performed on the acceptor.
+ *
+ * @param ec Set to indicate what error occurred, if any.
+ *
+ * @sa IoControlCommand @n
+ * boost::asio::socket_base::non_blocking_io
+ *
+ * @par Example
+ * Getting the number of bytes ready to read:
+ * @code
+ * boost::asio::ip::tcp::acceptor acceptor(io_service);
+ * ...
+ * boost::asio::ip::tcp::acceptor::non_blocking_io command(true);
+ * boost::system::error_code ec;
+ * socket.io_control(command, ec);
+ * if (ec)
+ * {
+ * // An error occurred.
+ * }
+ * @endcode
+ */
+ template <typename IoControlCommand>
+ boost::system::error_code io_control(IoControlCommand& command,
+ boost::system::error_code& ec)
+ {
+ return this->service.io_control(this->implementation, command, ec);
+ }
+
+ /// Gets the non-blocking mode of the acceptor.
+ /**
+ * @returns @c true if the acceptor's synchronous operations will fail with
+ * boost::asio::error::would_block if they are unable to perform the requested
+ * operation immediately. If @c false, synchronous operations will block
+ * until complete.
+ *
+ * @note The non-blocking mode has no effect on the behaviour of asynchronous
+ * operations. Asynchronous operations will never fail with the error
+ * boost::asio::error::would_block.
+ */
+ bool non_blocking() const
+ {
+ return this->service.non_blocking(this->implementation);
+ }
+
+ /// Sets the non-blocking mode of the acceptor.
+ /**
+ * @param mode If @c true, the acceptor's synchronous operations will fail
+ * with boost::asio::error::would_block if they are unable to perform the
+ * requested operation immediately. If @c false, synchronous operations will
+ * block until complete.
+ *
+ * @throws boost::system::system_error Thrown on failure.
+ *
+ * @note The non-blocking mode has no effect on the behaviour of asynchronous
+ * operations. Asynchronous operations will never fail with the error
+ * boost::asio::error::would_block.
+ */
+ void non_blocking(bool mode)
+ {
+ boost::system::error_code ec;
+ this->service.non_blocking(this->implementation, mode, ec);
+ boost::asio::detail::throw_error(ec);
+ }
+
+ /// Sets the non-blocking mode of the acceptor.
+ /**
+ * @param mode If @c true, the acceptor's synchronous operations will fail
+ * with boost::asio::error::would_block if they are unable to perform the
+ * requested operation immediately. If @c false, synchronous operations will
+ * block until complete.
+ *
+ * @param ec Set to indicate what error occurred, if any.
+ *
+ * @note The non-blocking mode has no effect on the behaviour of asynchronous
+ * operations. Asynchronous operations will never fail with the error
+ * boost::asio::error::would_block.
+ */
+ boost::system::error_code non_blocking(
+ bool mode, boost::system::error_code& ec)
+ {
+ return this->service.non_blocking(this->implementation, mode, ec);
+ }
+
+ /// Gets the non-blocking mode of the native acceptor implementation.
+ /**
+ * This function is used to retrieve the non-blocking mode of the underlying
+ * native acceptor. This mode has no effect on the behaviour of the acceptor
+ * object's synchronous operations.
+ *
+ * @returns @c true if the underlying acceptor is in non-blocking mode and
+ * direct system calls may fail with boost::asio::error::would_block (or the
+ * equivalent system error).
+ *
+ * @note The current non-blocking mode is cached by the acceptor object.
+ * Consequently, the return value may be incorrect if the non-blocking mode
+ * was set directly on the native acceptor.
+ */
+ bool native_non_blocking() const
+ {
+ return this->service.native_non_blocking(this->implementation);
+ }
+
+ /// Sets the non-blocking mode of the native acceptor implementation.
+ /**
+ * This function is used to modify the non-blocking mode of the underlying
+ * native acceptor. It has no effect on the behaviour of the acceptor object's
+ * synchronous operations.
+ *
+ * @param mode If @c true, the underlying acceptor is put into non-blocking
+ * mode and direct system calls may fail with boost::asio::error::would_block
+ * (or the equivalent system error).
+ *
+ * @throws boost::system::system_error Thrown on failure. If the @c mode is
+ * @c false, but the current value of @c non_blocking() is @c true, this
+ * function fails with boost::asio::error::invalid_argument, as the
+ * combination does not make sense.
+ */
+ void native_non_blocking(bool mode)
+ {
+ boost::system::error_code ec;
+ this->service.native_non_blocking(this->implementation, mode, ec);
+ boost::asio::detail::throw_error(ec);
+ }
+
+ /// Sets the non-blocking mode of the native acceptor implementation.
+ /**
+ * This function is used to modify the non-blocking mode of the underlying
+ * native acceptor. It has no effect on the behaviour of the acceptor object's
+ * synchronous operations.
+ *
+ * @param mode If @c true, the underlying acceptor is put into non-blocking
+ * mode and direct system calls may fail with boost::asio::error::would_block
+ * (or the equivalent system error).
+ *
+ * @param ec Set to indicate what error occurred, if any. If the @c mode is
+ * @c false, but the current value of @c non_blocking() is @c true, this
+ * function fails with boost::asio::error::invalid_argument, as the
+ * combination does not make sense.
+ */
+ boost::system::error_code native_non_blocking(
+ bool mode, boost::system::error_code& ec)
+ {
+ return this->service.native_non_blocking(this->implementation, mode, ec);
+ }
+
   /// Get the local endpoint of the acceptor.
   /**
    * This function is used to obtain the locally bound endpoint of the acceptor.
@@ -713,7 +907,12 @@
   void async_accept(basic_socket<protocol_type, SocketService>& peer,
       AcceptHandler handler)
   {
- this->service.async_accept(this->implementation, peer, 0, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a AcceptHandler.
+ BOOST_ASIO_ACCEPT_HANDLER_CHECK(AcceptHandler, handler) type_check;
+
+ this->service.async_accept(this->implementation, peer, 0,
+ BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler));
   }
 
   /// Accept a new connection and obtain the endpoint of the peer
@@ -814,8 +1013,12 @@
   void async_accept(basic_socket<protocol_type, SocketService>& peer,
       endpoint_type& peer_endpoint, AcceptHandler handler)
   {
- this->service.async_accept(this->implementation,
- peer, &peer_endpoint, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a AcceptHandler.
+ BOOST_ASIO_ACCEPT_HANDLER_CHECK(AcceptHandler, handler) type_check;
+
+ this->service.async_accept(this->implementation, peer,
+ &peer_endpoint, BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler));
   }
 };
 

Modified: trunk/boost/asio/basic_socket_iostream.hpp
==============================================================================
--- trunk/boost/asio/basic_socket_iostream.hpp (original)
+++ trunk/boost/asio/basic_socket_iostream.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -35,7 +35,8 @@
 // template <typename T1, ..., typename Tn>
 // explicit basic_socket_iostream(T1 x1, ..., Tn xn)
 // : basic_iostream<char>(&this->boost::base_from_member<
-// basic_socket_streambuf<Protocol, StreamSocketService> >::member)
+// basic_socket_streambuf<Protocol, StreamSocketService,
+// Time, TimeTraits, TimerService> >::member)
 // {
 // if (rdbuf()->connect(x1, ..., xn) == 0)
 // this->setstate(std::ios_base::failbit);
@@ -46,7 +47,8 @@
   template <BOOST_PP_ENUM_PARAMS(n, typename T)> \
   explicit basic_socket_iostream(BOOST_PP_ENUM_BINARY_PARAMS(n, T, x)) \
     : std::basic_iostream<char>(&this->boost::base_from_member< \
- basic_socket_streambuf<Protocol, StreamSocketService> >::member) \
+ basic_socket_streambuf<Protocol, StreamSocketService, \
+ Time, TimeTraits, TimerService> >::member) \
   { \
     tie(this); \
     if (rdbuf()->connect(BOOST_PP_ENUM_PARAMS(n, x)) == 0) \
@@ -79,17 +81,31 @@
 
 /// Iostream interface for a socket.
 template <typename Protocol,
- typename StreamSocketService = stream_socket_service<Protocol> >
+ typename StreamSocketService = stream_socket_service<Protocol>,
+ typename Time = boost::posix_time::ptime,
+ typename TimeTraits = boost::asio::time_traits<Time>,
+ typename TimerService = deadline_timer_service<Time, TimeTraits> >
 class basic_socket_iostream
   : public boost::base_from_member<
- basic_socket_streambuf<Protocol, StreamSocketService> >,
+ basic_socket_streambuf<Protocol, StreamSocketService,
+ Time, TimeTraits, TimerService> >,
     public std::basic_iostream<char>
 {
 public:
+ /// The endpoint type.
+ typedef typename Protocol::endpoint endpoint_type;
+
+ /// The time type.
+ typedef typename TimeTraits::time_type time_type;
+
+ /// The duration type.
+ typedef typename TimeTraits::duration_type duration_type;
+
   /// Construct a basic_socket_iostream without establishing a connection.
   basic_socket_iostream()
     : std::basic_iostream<char>(&this->boost::base_from_member<
- basic_socket_streambuf<Protocol, StreamSocketService> >::member)
+ basic_socket_streambuf<Protocol, StreamSocketService,
+ Time, TimeTraits, TimerService> >::member)
   {
     tie(this);
   }
@@ -132,11 +148,77 @@
   }
 
   /// Return a pointer to the underlying streambuf.
- basic_socket_streambuf<Protocol, StreamSocketService>* rdbuf() const
+ basic_socket_streambuf<Protocol, StreamSocketService,
+ Time, TimeTraits, TimerService>* rdbuf() const
   {
- return const_cast<basic_socket_streambuf<Protocol, StreamSocketService>*>(
+ return const_cast<basic_socket_streambuf<Protocol, StreamSocketService,
+ Time, TimeTraits, TimerService>*>(
         &this->boost::base_from_member<
- basic_socket_streambuf<Protocol, StreamSocketService> >::member);
+ basic_socket_streambuf<Protocol, StreamSocketService,
+ Time, TimeTraits, TimerService> >::member);
+ }
+
+ /// Get the last error associated with the stream.
+ /**
+ * @return An \c error_code corresponding to the last error from the stream.
+ *
+ * @par Example
+ * To print the error associated with a failure to establish a connection:
+ * @code tcp::iostream s("www.boost.org", "http");
+ * if (!s)
+ * {
+ * std::cout << "Error: " << s.error().message() << std::endl;
+ * } @endcode
+ */
+ const boost::system::error_code& error() const
+ {
+ return rdbuf()->puberror();
+ }
+
+ /// Get the stream's expiry time as an absolute time.
+ /**
+ * @return An absolute time value representing the stream's expiry time.
+ */
+ time_type expires_at() const
+ {
+ return rdbuf()->expires_at();
+ }
+
+ /// Set the stream's expiry time as an absolute time.
+ /**
+ * This function sets the expiry time associated with the stream. Stream
+ * operations performed after this time (where the operations cannot be
+ * completed using the internal buffers) will fail with the error
+ * boost::asio::error::operation_aborted.
+ *
+ * @param expiry_time The expiry time to be used for the stream.
+ */
+ void expires_at(const time_type& expiry_time)
+ {
+ rdbuf()->expires_at(expiry_time);
+ }
+
+ /// Get the timer's expiry time relative to now.
+ /**
+ * @return A relative time value representing the stream's expiry time.
+ */
+ duration_type expires_from_now() const
+ {
+ return rdbuf()->expires_from_now();
+ }
+
+ /// Set the stream's expiry time relative to now.
+ /**
+ * This function sets the expiry time associated with the stream. Stream
+ * operations performed after this time (where the operations cannot be
+ * completed using the internal buffers) will fail with the error
+ * boost::asio::error::operation_aborted.
+ *
+ * @param expiry_time The expiry time to be used for the timer.
+ */
+ void expires_from_now(const duration_type& expiry_time)
+ {
+ rdbuf()->expires_from_now(expiry_time);
   }
 };
 

Modified: trunk/boost/asio/basic_socket_streambuf.hpp
==============================================================================
--- trunk/boost/asio/basic_socket_streambuf.hpp (original)
+++ trunk/boost/asio/basic_socket_streambuf.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -27,9 +27,15 @@
 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
 #include <boost/utility/base_from_member.hpp>
 #include <boost/asio/basic_socket.hpp>
+#include <boost/asio/deadline_timer_service.hpp>
 #include <boost/asio/detail/throw_error.hpp>
 #include <boost/asio/io_service.hpp>
 #include <boost/asio/stream_socket_service.hpp>
+#include <boost/asio/time_traits.hpp>
+
+#include <boost/asio/detail/push_options.hpp>
+#include <boost/date_time/posix_time/posix_time_types.hpp>
+#include <boost/asio/detail/pop_options.hpp>
 
 #if !defined(BOOST_ASIO_SOCKET_STREAMBUF_MAX_ARITY)
 #define BOOST_ASIO_SOCKET_STREAMBUF_MAX_ARITY 5
@@ -37,33 +43,33 @@
 
 // A macro that should expand to:
 // template <typename T1, ..., typename Tn>
-// basic_socket_streambuf<Protocol, StreamSocketService>* connect(
+// basic_socket_streambuf<Protocol, StreamSocketService,
+// Time, TimeTraits, TimerService>* connect(
 // T1 x1, ..., Tn xn)
 // {
 // init_buffers();
-// boost::system::error_code ec;
-// this->basic_socket<Protocol, StreamSocketService>::close(ec);
+// this->basic_socket<Protocol, StreamSocketService>::close(ec_);
 // typedef typename Protocol::resolver resolver_type;
 // typedef typename resolver_type::query resolver_query;
 // resolver_query query(x1, ..., xn);
-// resolve_and_connect(query, ec);
-// return !ec ? this : 0;
+// resolve_and_connect(query);
+// return !ec_ ? this : 0;
 // }
 // This macro should only persist within this file.
 
 #define BOOST_ASIO_PRIVATE_CONNECT_DEF( z, n, data ) \
   template <BOOST_PP_ENUM_PARAMS(n, typename T)> \
- basic_socket_streambuf<Protocol, StreamSocketService>* connect( \
+ basic_socket_streambuf<Protocol, StreamSocketService, \
+ Time, TimeTraits, TimerService>* connect( \
       BOOST_PP_ENUM_BINARY_PARAMS(n, T, x)) \
   { \
     init_buffers(); \
- boost::system::error_code ec; \
- this->basic_socket<Protocol, StreamSocketService>::close(ec); \
+ this->basic_socket<Protocol, StreamSocketService>::close(ec_); \
     typedef typename Protocol::resolver resolver_type; \
     typedef typename resolver_type::query resolver_query; \
     resolver_query query(BOOST_PP_ENUM_PARAMS(n, x)); \
- resolve_and_connect(query, ec); \
- return !ec ? this : 0; \
+ resolve_and_connect(query); \
+ return !ec_ ? this : 0; \
   } \
   /**/
 
@@ -74,7 +80,10 @@
 
 /// Iostream streambuf for a socket.
 template <typename Protocol,
- typename StreamSocketService = stream_socket_service<Protocol> >
+ typename StreamSocketService = stream_socket_service<Protocol>,
+ typename Time = boost::posix_time::ptime,
+ typename TimeTraits = boost::asio::time_traits<Time>,
+ typename TimerService = deadline_timer_service<Time, TimeTraits> >
 class basic_socket_streambuf
   : public std::streambuf,
     private boost::base_from_member<io_service>,
@@ -84,11 +93,19 @@
   /// The endpoint type.
   typedef typename Protocol::endpoint endpoint_type;
 
+ /// The time type.
+ typedef typename TimeTraits::time_type time_type;
+
+ /// The duration type.
+ typedef typename TimeTraits::duration_type duration_type;
+
   /// Construct a basic_socket_streambuf without establishing a connection.
   basic_socket_streambuf()
     : basic_socket<Protocol, StreamSocketService>(
         boost::base_from_member<boost::asio::io_service>::member),
- unbuffered_(false)
+ unbuffered_(false),
+ timer_service_(0),
+ timer_state_(no_timer)
   {
     init_buffers();
   }
@@ -98,6 +115,8 @@
   {
     if (pptr() != pbase())
       overflow(traits_type::eof());
+
+ destroy_timer();
   }
 
   /// Establish a connection.
@@ -107,14 +126,30 @@
    * @return \c this if a connection was successfully established, a null
    * pointer otherwise.
    */
- basic_socket_streambuf<Protocol, StreamSocketService>* connect(
+ basic_socket_streambuf<Protocol, StreamSocketService,
+ Time, TimeTraits, TimerService>* connect(
       const endpoint_type& endpoint)
   {
     init_buffers();
- boost::system::error_code ec;
- this->basic_socket<Protocol, StreamSocketService>::close(ec);
- this->basic_socket<Protocol, StreamSocketService>::connect(endpoint, ec);
- return !ec ? this : 0;
+
+ this->basic_socket<Protocol, StreamSocketService>::close(ec_);
+
+ if (timer_state_ == timer_has_expired)
+ {
+ ec_ = boost::asio::error::operation_aborted;
+ return 0;
+ }
+
+ io_handler handler = { this };
+ this->basic_socket<Protocol, StreamSocketService>::async_connect(
+ endpoint, handler);
+
+ ec_ = boost::asio::error::would_block;
+ this->service.get_io_service().reset();
+ do this->service.get_io_service().run_one();
+ while (ec_ == boost::asio::error::would_block);
+
+ return !ec_ ? this : 0;
   }
 
 #if defined(GENERATING_DOCUMENTATION)
@@ -141,14 +176,85 @@
    * @return \c this if a connection was successfully established, a null
    * pointer otherwise.
    */
- basic_socket_streambuf<Protocol, StreamSocketService>* close()
+ basic_socket_streambuf<Protocol, StreamSocketService,
+ Time, TimeTraits, TimerService>* close()
   {
- boost::system::error_code ec;
     sync();
- this->basic_socket<Protocol, StreamSocketService>::close(ec);
- if (!ec)
+ this->basic_socket<Protocol, StreamSocketService>::close(ec_);
+ if (!ec_)
       init_buffers();
- return !ec ? this : 0;
+ return !ec_ ? this : 0;
+ }
+
+ /// Get the last error associated with the stream buffer.
+ /**
+ * @return An \c error_code corresponding to the last error from the stream
+ * buffer.
+ */
+ const boost::system::error_code& puberror() const
+ {
+ return error();
+ }
+
+ /// Get the stream buffer's expiry time as an absolute time.
+ /**
+ * @return An absolute time value representing the stream buffer's expiry
+ * time.
+ */
+ time_type expires_at() const
+ {
+ return timer_service_
+ ? timer_service_->expires_at(timer_implementation_)
+ : time_type();
+ }
+
+ /// Set the stream buffer's expiry time as an absolute time.
+ /**
+ * This function sets the expiry time associated with the stream. Stream
+ * operations performed after this time (where the operations cannot be
+ * completed using the internal buffers) will fail with the error
+ * boost::asio::error::operation_aborted.
+ *
+ * @param expiry_time The expiry time to be used for the stream.
+ */
+ void expires_at(const time_type& expiry_time)
+ {
+ construct_timer();
+
+ boost::system::error_code ec;
+ timer_service_->expires_at(timer_implementation_, expiry_time, ec);
+ boost::asio::detail::throw_error(ec);
+
+ start_timer();
+ }
+
+ /// Get the stream buffer's expiry time relative to now.
+ /**
+ * @return A relative time value representing the stream buffer's expiry time.
+ */
+ duration_type expires_from_now() const
+ {
+ return TimeTraits::subtract(expires_at(), TimeTraits::now());
+ }
+
+ /// Set the stream buffer's expiry time relative to now.
+ /**
+ * This function sets the expiry time associated with the stream. Stream
+ * operations performed after this time (where the operations cannot be
+ * completed using the internal buffers) will fail with the error
+ * boost::asio::error::operation_aborted.
+ *
+ * @param expiry_time The expiry time to be used for the timer.
+ */
+ void expires_from_now(const duration_type& expiry_time)
+ {
+ construct_timer();
+
+ boost::system::error_code ec;
+ timer_service_->expires_from_now(timer_implementation_, expiry_time, ec);
+ boost::asio::detail::throw_error(ec);
+
+ start_timer();
   }
 
 protected:
@@ -156,15 +262,26 @@
   {
     if (gptr() == egptr())
     {
- boost::system::error_code ec;
- std::size_t bytes_transferred = this->service.receive(
- this->implementation,
+ if (timer_state_ == timer_has_expired)
+ {
+ ec_ = boost::asio::error::operation_aborted;
+ return traits_type::eof();
+ }
+
+ io_handler handler = { this };
+ this->service.async_receive(this->implementation,
           boost::asio::buffer(boost::asio::buffer(get_buffer_) + putback_max),
- 0, ec);
- if (ec)
+ 0, handler);
+
+ ec_ = boost::asio::error::would_block;
+ this->service.get_io_service().reset();
+ do this->service.get_io_service().run_one();
+ while (ec_ == boost::asio::error::would_block);
+ if (ec_)
         return traits_type::eof();
+
       setg(get_buffer_.begin(), get_buffer_.begin() + putback_max,
- get_buffer_.begin() + putback_max + bytes_transferred);
+ get_buffer_.begin() + putback_max + bytes_transferred_);
       return traits_type::to_int_type(*gptr());
     }
     else
@@ -184,13 +301,25 @@
       }
       else
       {
+ if (timer_state_ == timer_has_expired)
+ {
+ ec_ = boost::asio::error::operation_aborted;
+ return traits_type::eof();
+ }
+
         // Send the single character immediately.
- boost::system::error_code ec;
         char_type ch = traits_type::to_char_type(c);
- this->service.send(this->implementation,
- boost::asio::buffer(&ch, sizeof(char_type)), 0, ec);
- if (ec)
+ io_handler handler = { this };
+ this->service.async_send(this->implementation,
+ boost::asio::buffer(&ch, sizeof(char_type)), 0, handler);
+
+ ec_ = boost::asio::error::would_block;
+ this->service.get_io_service().reset();
+ do this->service.get_io_service().run_one();
+ while (ec_ == boost::asio::error::would_block);
+ if (ec_)
           return traits_type::eof();
+
         return c;
       }
     }
@@ -201,13 +330,24 @@
         boost::asio::buffer(pbase(), pptr() - pbase());
       while (boost::asio::buffer_size(buffer) > 0)
       {
- boost::system::error_code ec;
- std::size_t bytes_transferred = this->service.send(
- this->implementation, boost::asio::buffer(buffer),
- 0, ec);
- if (ec)
+ if (timer_state_ == timer_has_expired)
+ {
+ ec_ = boost::asio::error::operation_aborted;
+ return traits_type::eof();
+ }
+
+ io_handler handler = { this };
+ this->service.async_send(this->implementation,
+ boost::asio::buffer(buffer), 0, handler);
+
+ ec_ = boost::asio::error::would_block;
+ this->service.get_io_service().reset();
+ do this->service.get_io_service().run_one();
+ while (ec_ == boost::asio::error::would_block);
+ if (ec_)
           return traits_type::eof();
- buffer = buffer + bytes_transferred;
+
+ buffer = buffer + bytes_transferred_;
       }
       setp(put_buffer_.begin(), put_buffer_.end());
 
@@ -239,6 +379,16 @@
     return 0;
   }
 
+ /// Get the last error associated with the stream buffer.
+ /**
+ * @return An \c error_code corresponding to the last error from the stream
+ * buffer.
+ */
+ virtual const boost::system::error_code& error() const
+ {
+ return ec_;
+ }
+
 private:
   void init_buffers()
   {
@@ -252,32 +402,118 @@
   }
 
   template <typename ResolverQuery>
- void resolve_and_connect(const ResolverQuery& query,
- boost::system::error_code& ec)
+ void resolve_and_connect(const ResolverQuery& query)
   {
     typedef typename Protocol::resolver resolver_type;
     typedef typename resolver_type::iterator iterator_type;
     resolver_type resolver(
         boost::base_from_member<boost::asio::io_service>::member);
- iterator_type i = resolver.resolve(query, ec);
- if (!ec)
+ iterator_type i = resolver.resolve(query, ec_);
+ if (!ec_)
     {
       iterator_type end;
- ec = boost::asio::error::host_not_found;
- while (ec && i != end)
+ ec_ = boost::asio::error::host_not_found;
+ while (ec_ && i != end)
       {
- this->basic_socket<Protocol, StreamSocketService>::close();
- this->basic_socket<Protocol, StreamSocketService>::connect(*i, ec);
+ this->basic_socket<Protocol, StreamSocketService>::close(ec_);
+
+ if (timer_state_ == timer_has_expired)
+ {
+ ec_ = boost::asio::error::operation_aborted;
+ return;
+ }
+
+ io_handler handler = { this };
+ this->basic_socket<Protocol, StreamSocketService>::async_connect(
+ *i, handler);
+
+ ec_ = boost::asio::error::would_block;
+ this->service.get_io_service().reset();
+ do this->service.get_io_service().run_one();
+ while (ec_ == boost::asio::error::would_block);
+
         ++i;
       }
     }
   }
 
+ struct io_handler;
+ friend struct io_handler;
+ struct io_handler
+ {
+ basic_socket_streambuf* this_;
+
+ void operator()(const boost::system::error_code& ec,
+ std::size_t bytes_transferred = 0)
+ {
+ this_->ec_ = ec;
+ this_->bytes_transferred_ = bytes_transferred;
+ }
+ };
+
+ struct timer_handler;
+ friend struct timer_handler;
+ struct timer_handler
+ {
+ basic_socket_streambuf* this_;
+
+ void operator()(const boost::system::error_code&)
+ {
+ time_type now = TimeTraits::now();
+
+ time_type expiry_time = this_->timer_service_->expires_at(
+ this_->timer_implementation_);
+
+ if (TimeTraits::less_than(now, expiry_time))
+ {
+ this_->timer_state_ = timer_is_pending;
+ this_->timer_service_->async_wait(this_->timer_implementation_, *this);
+ }
+ else
+ {
+ this_->timer_state_ = timer_has_expired;
+ boost::system::error_code ec;
+ this_->basic_socket<Protocol, StreamSocketService>::close(ec);
+ }
+ }
+ };
+
+ void construct_timer()
+ {
+ if (timer_service_ == 0)
+ {
+ TimerService& timer_service = use_service<TimerService>(
+ boost::base_from_member<boost::asio::io_service>::member);
+ timer_service.construct(timer_implementation_);
+ timer_service_ = &timer_service;
+ }
+ }
+
+ void destroy_timer()
+ {
+ if (timer_service_)
+ timer_service_->destroy(timer_implementation_);
+ }
+
+ void start_timer()
+ {
+ if (timer_state_ != timer_is_pending)
+ {
+ timer_handler handler = { this };
+ handler(boost::system::error_code());
+ }
+ }
+
   enum { putback_max = 8 };
   enum { buffer_size = 512 };
   boost::array<char, buffer_size> get_buffer_;
   boost::array<char, buffer_size> put_buffer_;
   bool unbuffered_;
+ boost::system::error_code ec_;
+ std::size_t bytes_transferred_;
+ TimerService* timer_service_;
+ typename TimerService::implementation_type timer_implementation_;
+ enum state { no_timer, timer_is_pending, timer_has_expired } timer_state_;
 };
 
 } // namespace asio

Modified: trunk/boost/asio/basic_stream_socket.hpp
==============================================================================
--- trunk/boost/asio/basic_stream_socket.hpp (original)
+++ trunk/boost/asio/basic_stream_socket.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -18,6 +18,7 @@
 #include <boost/asio/detail/config.hpp>
 #include <cstddef>
 #include <boost/asio/basic_socket.hpp>
+#include <boost/asio/detail/handler_type_requirements.hpp>
 #include <boost/asio/detail/throw_error.hpp>
 #include <boost/asio/error.hpp>
 #include <boost/asio/stream_socket_service.hpp>
@@ -45,8 +46,12 @@
   : public basic_socket<Protocol, StreamSocketService>
 {
 public:
+ /// (Deprecated: Use native_handle_type.) The native representation of a
+ /// socket.
+ typedef typename StreamSocketService::native_handle_type native_type;
+
   /// The native representation of a socket.
- typedef typename StreamSocketService::native_type native_type;
+ typedef typename StreamSocketService::native_handle_type native_handle_type;
 
   /// The protocol type.
   typedef Protocol protocol_type;
@@ -122,7 +127,7 @@
    * @throws boost::system::system_error Thrown on failure.
    */
   basic_stream_socket(boost::asio::io_service& io_service,
- const protocol_type& protocol, const native_type& native_socket)
+ const protocol_type& protocol, const native_handle_type& native_socket)
     : basic_socket<Protocol, StreamSocketService>(
         io_service, protocol, native_socket)
   {
@@ -264,7 +269,12 @@
   template <typename ConstBufferSequence, typename WriteHandler>
   void async_send(const ConstBufferSequence& buffers, WriteHandler handler)
   {
- this->service.async_send(this->implementation, buffers, 0, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a WriteHandler.
+ BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
+
+ this->service.async_send(this->implementation, buffers, 0,
+ BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
   /// Start an asynchronous send.
@@ -308,7 +318,12 @@
   void async_send(const ConstBufferSequence& buffers,
       socket_base::message_flags flags, WriteHandler handler)
   {
- this->service.async_send(this->implementation, buffers, flags, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a WriteHandler.
+ BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
+
+ this->service.async_send(this->implementation, buffers, flags,
+ BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
   /// Receive some data on the socket.
@@ -454,7 +469,12 @@
   template <typename MutableBufferSequence, typename ReadHandler>
   void async_receive(const MutableBufferSequence& buffers, ReadHandler handler)
   {
- this->service.async_receive(this->implementation, buffers, 0, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
+ this->service.async_receive(this->implementation, buffers, 0,
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 
   /// Start an asynchronous receive.
@@ -500,7 +520,12 @@
   void async_receive(const MutableBufferSequence& buffers,
       socket_base::message_flags flags, ReadHandler handler)
   {
- this->service.async_receive(this->implementation, buffers, flags, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
+ this->service.async_receive(this->implementation, buffers, flags,
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 
   /// Write some data to the socket.
@@ -601,7 +626,12 @@
   void async_write_some(const ConstBufferSequence& buffers,
       WriteHandler handler)
   {
- this->service.async_send(this->implementation, buffers, 0, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a WriteHandler.
+ BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
+
+ this->service.async_send(this->implementation, buffers, 0,
+ BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
   /// Read some data from the socket.
@@ -705,7 +735,12 @@
   void async_read_some(const MutableBufferSequence& buffers,
       ReadHandler handler)
   {
- this->service.async_receive(this->implementation, buffers, 0, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
+ this->service.async_receive(this->implementation, buffers, 0,
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 };
 

Modified: trunk/boost/asio/basic_streambuf.hpp
==============================================================================
--- trunk/boost/asio/basic_streambuf.hpp (original)
+++ trunk/boost/asio/basic_streambuf.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -130,9 +130,9 @@
    * of the streambuf's input sequence is 0.
    */
   explicit basic_streambuf(
- std::size_t max_size = (std::numeric_limits<std::size_t>::max)(),
+ std::size_t maximum_size = (std::numeric_limits<std::size_t>::max)(),
       const Allocator& allocator = Allocator())
- : max_size_(max_size),
+ : max_size_(maximum_size),
       buffer_(allocator)
   {
     std::size_t pend = (std::min<std::size_t>)(max_size_, buffer_delta);

Modified: trunk/boost/asio/buffer.hpp
==============================================================================
--- trunk/boost/asio/buffer.hpp (original)
+++ trunk/boost/asio/buffer.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -17,6 +17,7 @@
 
 #include <boost/asio/detail/config.hpp>
 #include <cstddef>
+#include <cstring>
 #include <string>
 #include <vector>
 #include <boost/detail/workaround.hpp>
@@ -68,6 +69,19 @@
  * The mutable_buffer class provides a safe representation of a buffer that can
  * be modified. It does not own the underlying data, and so is cheap to copy or
  * assign.
+ *
+ * @par Accessing Buffer Contents
+ *
+ * The contents of a buffer may be accessed using the @ref buffer_size
+ * and @ref buffer_cast functions:
+ *
+ * @code boost::asio::mutable_buffer b1 = ...;
+ * std::size_t s1 = boost::asio::buffer_size(b1);
+ * unsigned char* p1 = boost::asio::buffer_cast<unsigned char*>(b1);
+ * @endcode
+ *
+ * The boost::asio::buffer_cast function permits violations of type safety, so
+ * uses of it in application code should be carefully considered.
  */
 class mutable_buffer
 {
@@ -133,59 +147,6 @@
 
 } // namespace detail
 
-/// Cast a non-modifiable buffer to a specified pointer to POD type.
-/**
- * @relates mutable_buffer
- */
-template <typename PointerToPodType>
-inline PointerToPodType buffer_cast(const mutable_buffer& b)
-{
- return static_cast<PointerToPodType>(detail::buffer_cast_helper(b));
-}
-
-/// Get the number of bytes in a non-modifiable buffer.
-/**
- * @relates mutable_buffer
- */
-inline std::size_t buffer_size(const mutable_buffer& b)
-{
- return detail::buffer_size_helper(b);
-}
-
-/// Create a new modifiable buffer that is offset from the start of another.
-/**
- * @relates mutable_buffer
- */
-inline mutable_buffer operator+(const mutable_buffer& b, std::size_t start)
-{
- if (start > buffer_size(b))
- return mutable_buffer();
- char* new_data = buffer_cast<char*>(b) + start;
- std::size_t new_size = buffer_size(b) - start;
- return mutable_buffer(new_data, new_size
-#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
- , b.get_debug_check()
-#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING
- );
-}
-
-/// Create a new modifiable buffer that is offset from the start of another.
-/**
- * @relates mutable_buffer
- */
-inline mutable_buffer operator+(std::size_t start, const mutable_buffer& b)
-{
- if (start > buffer_size(b))
- return mutable_buffer();
- char* new_data = buffer_cast<char*>(b) + start;
- std::size_t new_size = buffer_size(b) - start;
- return mutable_buffer(new_data, new_size
-#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
- , b.get_debug_check()
-#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING
- );
-}
-
 /// Adapts a single modifiable buffer so that it meets the requirements of the
 /// MutableBufferSequence concept.
 class mutable_buffers_1
@@ -228,6 +189,19 @@
  * The const_buffer class provides a safe representation of a buffer that cannot
  * be modified. It does not own the underlying data, and so is cheap to copy or
  * assign.
+ *
+ * @par Accessing Buffer Contents
+ *
+ * The contents of a buffer may be accessed using the @ref buffer_size
+ * and @ref buffer_cast functions:
+ *
+ * @code boost::asio::const_buffer b1 = ...;
+ * std::size_t s1 = boost::asio::buffer_size(b1);
+ * const unsigned char* p1 = boost::asio::buffer_cast<const unsigned char*>(b1);
+ * @endcode
+ *
+ * The boost::asio::buffer_cast function permits violations of type safety, so
+ * uses of it in application code should be carefully considered.
  */
 class const_buffer
 {
@@ -303,59 +277,6 @@
 
 } // namespace detail
 
-/// Cast a non-modifiable buffer to a specified pointer to POD type.
-/**
- * @relates const_buffer
- */
-template <typename PointerToPodType>
-inline PointerToPodType buffer_cast(const const_buffer& b)
-{
- return static_cast<PointerToPodType>(detail::buffer_cast_helper(b));
-}
-
-/// Get the number of bytes in a non-modifiable buffer.
-/**
- * @relates const_buffer
- */
-inline std::size_t buffer_size(const const_buffer& b)
-{
- return detail::buffer_size_helper(b);
-}
-
-/// Create a new non-modifiable buffer that is offset from the start of another.
-/**
- * @relates const_buffer
- */
-inline const_buffer operator+(const const_buffer& b, std::size_t start)
-{
- if (start > buffer_size(b))
- return const_buffer();
- const char* new_data = buffer_cast<const char*>(b) + start;
- std::size_t new_size = buffer_size(b) - start;
- return const_buffer(new_data, new_size
-#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
- , b.get_debug_check()
-#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING
- );
-}
-
-/// Create a new non-modifiable buffer that is offset from the start of another.
-/**
- * @relates const_buffer
- */
-inline const_buffer operator+(std::size_t start, const const_buffer& b)
-{
- if (start > buffer_size(b))
- return const_buffer();
- const char* new_data = buffer_cast<const char*>(b) + start;
- std::size_t new_size = buffer_size(b) - start;
- return const_buffer(new_data, new_size
-#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
- , b.get_debug_check()
-#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING
- );
-}
-
 /// Adapts a single non-modifiable buffer so that it meets the requirements of
 /// the ConstBufferSequence concept.
 class const_buffers_1
@@ -420,6 +341,163 @@
   mutable_buffer buf_;
 };
 
+/** @defgroup buffer_size boost::asio::buffer_size
+ *
+ * @brief The boost::asio::buffer_size function determines the total number of
+ * bytes in a buffer or buffer sequence.
+ */
+/*@{*/
+
+/// Get the number of bytes in a modifiable buffer.
+inline std::size_t buffer_size(const mutable_buffer& b)
+{
+ return detail::buffer_size_helper(b);
+}
+
+/// Get the number of bytes in a modifiable buffer.
+inline std::size_t buffer_size(const mutable_buffers_1& b)
+{
+ return detail::buffer_size_helper(b);
+}
+
+/// Get the number of bytes in a non-modifiable buffer.
+inline std::size_t buffer_size(const const_buffer& b)
+{
+ return detail::buffer_size_helper(b);
+}
+
+/// Get the number of bytes in a non-modifiable buffer.
+inline std::size_t buffer_size(const const_buffers_1& b)
+{
+ return detail::buffer_size_helper(b);
+}
+
+/// Get the total number of bytes in a buffer sequence.
+/**
+ * The @c BufferSequence template parameter may meet either of the @c
+ * ConstBufferSequence or @c MutableBufferSequence type requirements.
+ */
+template <typename BufferSequence>
+inline std::size_t buffer_size(const BufferSequence& b)
+{
+ std::size_t total_buffer_size = 0;
+
+ typename BufferSequence::const_iterator iter = b.begin();
+ typename BufferSequence::const_iterator end = b.end();
+ for (; iter != end; ++iter)
+ total_buffer_size += detail::buffer_size_helper(*iter);
+
+ return total_buffer_size;
+}
+
+/*@}*/
+
+/** @defgroup buffer_cast boost::asio::buffer_cast
+ *
+ * @brief The boost::asio::buffer_cast function is used to obtain a pointer to
+ * the underlying memory region associated with a buffer.
+ *
+ * @par Examples:
+ *
+ * To access the memory of a non-modifiable buffer, use:
+ * @code boost::asio::const_buffer b1 = ...;
+ * const unsigned char* p1 = boost::asio::buffer_cast<const unsigned char*>(b1);
+ * @endcode
+ *
+ * To access the memory of a modifiable buffer, use:
+ * @code boost::asio::mutable_buffer b2 = ...;
+ * unsigned char* p2 = boost::asio::buffer_cast<unsigned char*>(b2);
+ * @endcode
+ *
+ * The boost::asio::buffer_cast function permits violations of type safety, so
+ * uses of it in application code should be carefully considered.
+ */
+/*@{*/
+
+/// Cast a non-modifiable buffer to a specified pointer to POD type.
+template <typename PointerToPodType>
+inline PointerToPodType buffer_cast(const mutable_buffer& b)
+{
+ return static_cast<PointerToPodType>(detail::buffer_cast_helper(b));
+}
+
+/// Cast a non-modifiable buffer to a specified pointer to POD type.
+template <typename PointerToPodType>
+inline PointerToPodType buffer_cast(const const_buffer& b)
+{
+ return static_cast<PointerToPodType>(detail::buffer_cast_helper(b));
+}
+
+/*@}*/
+
+/// Create a new modifiable buffer that is offset from the start of another.
+/**
+ * @relates mutable_buffer
+ */
+inline mutable_buffer operator+(const mutable_buffer& b, std::size_t start)
+{
+ if (start > buffer_size(b))
+ return mutable_buffer();
+ char* new_data = buffer_cast<char*>(b) + start;
+ std::size_t new_size = buffer_size(b) - start;
+ return mutable_buffer(new_data, new_size
+#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
+ , b.get_debug_check()
+#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING
+ );
+}
+
+/// Create a new modifiable buffer that is offset from the start of another.
+/**
+ * @relates mutable_buffer
+ */
+inline mutable_buffer operator+(std::size_t start, const mutable_buffer& b)
+{
+ if (start > buffer_size(b))
+ return mutable_buffer();
+ char* new_data = buffer_cast<char*>(b) + start;
+ std::size_t new_size = buffer_size(b) - start;
+ return mutable_buffer(new_data, new_size
+#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
+ , b.get_debug_check()
+#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING
+ );
+}
+
+/// Create a new non-modifiable buffer that is offset from the start of another.
+/**
+ * @relates const_buffer
+ */
+inline const_buffer operator+(const const_buffer& b, std::size_t start)
+{
+ if (start > buffer_size(b))
+ return const_buffer();
+ const char* new_data = buffer_cast<const char*>(b) + start;
+ std::size_t new_size = buffer_size(b) - start;
+ return const_buffer(new_data, new_size
+#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
+ , b.get_debug_check()
+#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING
+ );
+}
+
+/// Create a new non-modifiable buffer that is offset from the start of another.
+/**
+ * @relates const_buffer
+ */
+inline const_buffer operator+(std::size_t start, const const_buffer& b)
+{
+ if (start > buffer_size(b))
+ return const_buffer();
+ const char* new_data = buffer_cast<const char*>(b) + start;
+ std::size_t new_size = buffer_size(b) - start;
+ return const_buffer(new_data, new_size
+#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
+ , b.get_debug_check()
+#endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING
+ );
+}
+
 #if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
 namespace detail {
 
@@ -499,8 +577,8 @@
  *
  * @par Accessing Buffer Contents
  *
- * The contents of a buffer may be accessed using the boost::asio::buffer_size
- * and boost::asio::buffer_cast functions:
+ * The contents of a buffer may be accessed using the @ref buffer_size and
+ * @ref buffer_cast functions:
  *
  * @code boost::asio::mutable_buffer b1 = ...;
  * std::size_t s1 = boost::asio::buffer_size(b1);
@@ -526,8 +604,8 @@
  * referring to the elements in the sequence (C++ Std, 23.2.4)
  *
  * For the boost::asio::buffer overloads that accept an argument of type
- * std::string, the buffer objects returned are invalidated according to the
- * rules defined for invalidation of references, pointers and iterators
+ * std::basic_string, the buffer objects returned are invalidated according to
+ * the rules defined for invalidation of references, pointers and iterators
  * referring to elements of the sequence (C++ Std, 21.3).
  *
  * @par Buffer Arithmetic
@@ -997,16 +1075,20 @@
 
 /// Create a new non-modifiable buffer that represents the given string.
 /**
- * @returns <tt>const_buffers_1(data.data(), data.size())</tt>.
+ * @returns <tt>const_buffers_1(data.data(), data.size() * sizeof(Elem))</tt>.
  *
  * @note The buffer is invalidated by any non-const operation called on the
  * given string object.
  */
-inline const_buffers_1 buffer(const std::string& data)
+template <typename Elem, typename Traits, typename Allocator>
+inline const_buffers_1 buffer(
+ const std::basic_string<Elem, Traits, Allocator>& data)
 {
- return const_buffers_1(const_buffer(data.data(), data.size()
+ return const_buffers_1(const_buffer(data.data(), data.size() * sizeof(Elem)
 #if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
- , detail::buffer_debug_check<std::string::const_iterator>(data.begin())
+ , detail::buffer_debug_check<
+ typename std::basic_string<Elem, Traits, Allocator>::const_iterator
+ >(data.begin())
 #endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING
         ));
 }
@@ -1016,26 +1098,924 @@
  * @returns A const_buffers_1 value equivalent to:
  * @code const_buffers_1(
  * data.data(),
- * min(data.size(), max_size_in_bytes)); @endcode
+ * min(data.size() * sizeof(Elem), max_size_in_bytes)); @endcode
  *
  * @note The buffer is invalidated by any non-const operation called on the
  * given string object.
  */
-inline const_buffers_1 buffer(const std::string& data,
+template <typename Elem, typename Traits, typename Allocator>
+inline const_buffers_1 buffer(
+ const std::basic_string<Elem, Traits, Allocator>& data,
     std::size_t max_size_in_bytes)
 {
   return const_buffers_1(
       const_buffer(data.data(),
- data.size() < max_size_in_bytes
- ? data.size() : max_size_in_bytes
+ data.size() * sizeof(Elem) < max_size_in_bytes
+ ? data.size() * sizeof(Elem) : max_size_in_bytes
 #if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
- , detail::buffer_debug_check<std::string::const_iterator>(data.begin())
+ , detail::buffer_debug_check<
+ typename std::basic_string<Elem, Traits, Allocator>::const_iterator
+ >(data.begin())
 #endif // BOOST_ASIO_ENABLE_BUFFER_DEBUGGING
         ));
 }
 
 /*@}*/
 
+/** @defgroup buffer_copy boost::asio::buffer_copy
+ *
+ * @brief The boost::asio::buffer_copy function is used to copy bytes from a
+ * source buffer (or buffer sequence) to a target buffer (or buffer sequence).
+ *
+ * The @c buffer_copy function is available in two forms:
+ *
+ * @li A 2-argument form: @c buffer_copy(target, source)
+ *
+ * @li A 3-argument form: @c buffer_copy(target, source, max_bytes_to_copy)
+
+ * Both forms return the number of bytes actually copied. The number of bytes
+ * copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ *
+ * @li @c If specified, @c max_bytes_to_copy.
+ *
+ * This prevents buffer overflow, regardless of the buffer sizes used in the
+ * copy operation.
+ */
+/*@{*/
+
+/// Copies bytes from a source buffer to a target buffer.
+/**
+ * @param target A modifiable buffer representing the memory region to which
+ * the bytes will be copied.
+ *
+ * @param source A non-modifiable buffer representing the memory region from
+ * which the bytes will be copied.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ */
+inline std::size_t buffer_copy(const mutable_buffer& target,
+ const const_buffer& source)
+{
+ using namespace std; // For memcpy.
+ std::size_t target_size = buffer_size(target);
+ std::size_t source_size = buffer_size(source);
+ std::size_t n = target_size < source_size ? target_size : source_size;
+ memcpy(buffer_cast<void*>(target), buffer_cast<const void*>(source), n);
+ return n;
+}
+
+/// Copies bytes from a source buffer to a target buffer.
+/**
+ * @param target A modifiable buffer representing the memory region to which
+ * the bytes will be copied.
+ *
+ * @param source A non-modifiable buffer representing the memory region from
+ * which the bytes will be copied.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ */
+inline std::size_t buffer_copy(const mutable_buffer& target,
+ const const_buffers_1& source)
+{
+ return buffer_copy(target, static_cast<const const_buffer&>(source));
+}
+
+/// Copies bytes from a source buffer to a target buffer.
+/**
+ * @param target A modifiable buffer representing the memory region to which
+ * the bytes will be copied.
+ *
+ * @param source A modifiable buffer representing the memory region from which
+ * the bytes will be copied. The contents of the source buffer will not be
+ * modified.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ */
+inline std::size_t buffer_copy(const mutable_buffer& target,
+ const mutable_buffer& source)
+{
+ return buffer_copy(target, const_buffer(source));
+}
+
+/// Copies bytes from a source buffer to a target buffer.
+/**
+ * @param target A modifiable buffer representing the memory region to which
+ * the bytes will be copied.
+ *
+ * @param source A modifiable buffer representing the memory region from which
+ * the bytes will be copied. The contents of the source buffer will not be
+ * modified.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ */
+inline std::size_t buffer_copy(const mutable_buffer& target,
+ const mutable_buffers_1& source)
+{
+ return buffer_copy(target, const_buffer(source));
+}
+
+/// Copies bytes from a source buffer sequence to a target buffer.
+/**
+ * @param target A modifiable buffer representing the memory region to which
+ * the bytes will be copied.
+ *
+ * @param source A non-modifiable buffer sequence representing the memory
+ * regions from which the bytes will be copied.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ */
+template <typename ConstBufferSequence>
+std::size_t buffer_copy(const mutable_buffer& target,
+ const ConstBufferSequence& source)
+{
+ std::size_t total_bytes_copied = 0;
+
+ typename ConstBufferSequence::const_iterator source_iter = source.begin();
+ typename ConstBufferSequence::const_iterator source_end = source.end();
+
+ for (mutable_buffer target_buffer(target);
+ buffer_size(target_buffer) && source_iter != source_end; ++source_iter)
+ {
+ const_buffer source_buffer(*source_iter);
+ std::size_t bytes_copied = buffer_copy(target_buffer, source_buffer);
+ total_bytes_copied += bytes_copied;
+ target_buffer = target_buffer + bytes_copied;
+ }
+
+ return total_bytes_copied;
+}
+
+/// Copies bytes from a source buffer to a target buffer.
+/**
+ * @param target A modifiable buffer representing the memory region to which
+ * the bytes will be copied.
+ *
+ * @param source A non-modifiable buffer representing the memory region from
+ * which the bytes will be copied.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ */
+inline std::size_t buffer_copy(const mutable_buffers_1& target,
+ const const_buffer& source)
+{
+ return buffer_copy(static_cast<const mutable_buffer&>(target), source);
+}
+
+/// Copies bytes from a source buffer to a target buffer.
+/**
+ * @param target A modifiable buffer representing the memory region to which
+ * the bytes will be copied.
+ *
+ * @param source A non-modifiable buffer representing the memory region from
+ * which the bytes will be copied.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ */
+inline std::size_t buffer_copy(const mutable_buffers_1& target,
+ const const_buffers_1& source)
+{
+ return buffer_copy(static_cast<const mutable_buffer&>(target),
+ static_cast<const const_buffer&>(source));
+}
+
+/// Copies bytes from a source buffer to a target buffer.
+/**
+ * @param target A modifiable buffer representing the memory region to which
+ * the bytes will be copied.
+ *
+ * @param source A modifiable buffer representing the memory region from which
+ * the bytes will be copied. The contents of the source buffer will not be
+ * modified.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ */
+inline std::size_t buffer_copy(const mutable_buffers_1& target,
+ const mutable_buffer& source)
+{
+ return buffer_copy(static_cast<const mutable_buffer&>(target),
+ const_buffer(source));
+}
+
+/// Copies bytes from a source buffer to a target buffer.
+/**
+ * @param target A modifiable buffer representing the memory region to which
+ * the bytes will be copied.
+ *
+ * @param source A modifiable buffer representing the memory region from which
+ * the bytes will be copied. The contents of the source buffer will not be
+ * modified.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ */
+inline std::size_t buffer_copy(const mutable_buffers_1& target,
+ const mutable_buffers_1& source)
+{
+ return buffer_copy(static_cast<const mutable_buffer&>(target),
+ const_buffer(source));
+}
+
+/// Copies bytes from a source buffer sequence to a target buffer.
+/**
+ * @param target A modifiable buffer representing the memory region to which
+ * the bytes will be copied.
+ *
+ * @param source A non-modifiable buffer sequence representing the memory
+ * regions from which the bytes will be copied.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ */
+template <typename ConstBufferSequence>
+inline std::size_t buffer_copy(const mutable_buffers_1& target,
+ const ConstBufferSequence& source)
+{
+ return buffer_copy(static_cast<const mutable_buffer&>(target), source);
+}
+
+/// Copies bytes from a source buffer to a target buffer sequence.
+/**
+ * @param target A modifiable buffer sequence representing the memory regions to
+ * which the bytes will be copied.
+ *
+ * @param source A non-modifiable buffer representing the memory region from
+ * which the bytes will be copied.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ */
+template <typename MutableBufferSequence>
+std::size_t buffer_copy(const MutableBufferSequence& target,
+ const const_buffer& source)
+{
+ std::size_t total_bytes_copied = 0;
+
+ typename MutableBufferSequence::const_iterator target_iter = target.begin();
+ typename MutableBufferSequence::const_iterator target_end = target.end();
+
+ for (const_buffer source_buffer(source);
+ buffer_size(source_buffer) && target_iter != target_end; ++target_iter)
+ {
+ mutable_buffer target_buffer(*target_iter);
+ std::size_t bytes_copied = buffer_copy(target_buffer, source_buffer);
+ total_bytes_copied += bytes_copied;
+ source_buffer = source_buffer + bytes_copied;
+ }
+
+ return total_bytes_copied;
+}
+
+/// Copies bytes from a source buffer to a target buffer sequence.
+/**
+ * @param target A modifiable buffer sequence representing the memory regions to
+ * which the bytes will be copied.
+ *
+ * @param source A non-modifiable buffer representing the memory region from
+ * which the bytes will be copied.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ */
+template <typename MutableBufferSequence>
+inline std::size_t buffer_copy(const MutableBufferSequence& target,
+ const const_buffers_1& source)
+{
+ return buffer_copy(target, static_cast<const const_buffer&>(source));
+}
+
+/// Copies bytes from a source buffer to a target buffer sequence.
+/**
+ * @param target A modifiable buffer sequence representing the memory regions to
+ * which the bytes will be copied.
+ *
+ * @param source A modifiable buffer representing the memory region from which
+ * the bytes will be copied. The contents of the source buffer will not be
+ * modified.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ */
+template <typename MutableBufferSequence>
+inline std::size_t buffer_copy(const MutableBufferSequence& target,
+ const mutable_buffer& source)
+{
+ return buffer_copy(target, const_buffer(source));
+}
+
+/// Copies bytes from a source buffer to a target buffer sequence.
+/**
+ * @param target A modifiable buffer sequence representing the memory regions to
+ * which the bytes will be copied.
+ *
+ * @param source A modifiable buffer representing the memory region from which
+ * the bytes will be copied. The contents of the source buffer will not be
+ * modified.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ */
+template <typename MutableBufferSequence>
+inline std::size_t buffer_copy(const MutableBufferSequence& target,
+ const mutable_buffers_1& source)
+{
+ return buffer_copy(target, const_buffer(source));
+}
+
+/// Copies bytes from a source buffer sequence to a target buffer sequence.
+/**
+ * @param target A modifiable buffer sequence representing the memory regions to
+ * which the bytes will be copied.
+ *
+ * @param source A non-modifiable buffer sequence representing the memory
+ * regions from which the bytes will be copied.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ */
+template <typename MutableBufferSequence, typename ConstBufferSequence>
+std::size_t buffer_copy(const MutableBufferSequence& target,
+ const ConstBufferSequence& source)
+{
+ std::size_t total_bytes_copied = 0;
+
+ typename MutableBufferSequence::const_iterator target_iter = target.begin();
+ typename MutableBufferSequence::const_iterator target_end = target.end();
+ std::size_t target_buffer_offset = 0;
+
+ typename ConstBufferSequence::const_iterator source_iter = source.begin();
+ typename ConstBufferSequence::const_iterator source_end = source.end();
+ std::size_t source_buffer_offset = 0;
+
+ while (target_iter != target_end && source_iter != source_end)
+ {
+ mutable_buffer target_buffer =
+ mutable_buffer(*target_iter) + target_buffer_offset;
+
+ const_buffer source_buffer =
+ const_buffer(*source_iter) + source_buffer_offset;
+
+ std::size_t bytes_copied = buffer_copy(target_buffer, source_buffer);
+ total_bytes_copied += bytes_copied;
+
+ if (bytes_copied == buffer_size(target_buffer))
+ {
+ ++target_iter;
+ target_buffer_offset = 0;
+ }
+ else
+ target_buffer_offset += bytes_copied;
+
+ if (bytes_copied == buffer_size(source_buffer))
+ {
+ ++source_iter;
+ source_buffer_offset = 0;
+ }
+ else
+ source_buffer_offset += bytes_copied;
+ }
+
+ return total_bytes_copied;
+}
+
+/// Copies a limited number of bytes from a source buffer to a target buffer.
+/**
+ * @param target A modifiable buffer representing the memory region to which
+ * the bytes will be copied.
+ *
+ * @param source A non-modifiable buffer representing the memory region from
+ * which the bytes will be copied.
+ *
+ * @param max_bytes_to_copy The maximum number of bytes to be copied.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ *
+ * @li @c max_bytes_to_copy
+ */
+inline std::size_t buffer_copy(const mutable_buffer& target,
+ const const_buffer& source, std::size_t max_bytes_to_copy)
+{
+ return buffer_copy(buffer(target, max_bytes_to_copy), source);
+}
+
+/// Copies a limited number of bytes from a source buffer to a target buffer.
+/**
+ * @param target A modifiable buffer representing the memory region to which
+ * the bytes will be copied.
+ *
+ * @param source A non-modifiable buffer representing the memory region from
+ * which the bytes will be copied.
+ *
+ * @param max_bytes_to_copy The maximum number of bytes to be copied.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ *
+ * @li @c max_bytes_to_copy
+ */
+inline std::size_t buffer_copy(const mutable_buffer& target,
+ const const_buffers_1& source, std::size_t max_bytes_to_copy)
+{
+ return buffer_copy(buffer(target, max_bytes_to_copy), source);
+}
+
+/// Copies a limited number of bytes from a source buffer to a target buffer.
+/**
+ * @param target A modifiable buffer representing the memory region to which
+ * the bytes will be copied.
+ *
+ * @param source A modifiable buffer representing the memory region from which
+ * the bytes will be copied. The contents of the source buffer will not be
+ * modified.
+ *
+ * @param max_bytes_to_copy The maximum number of bytes to be copied.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ *
+ * @li @c max_bytes_to_copy
+ */
+inline std::size_t buffer_copy(const mutable_buffer& target,
+ const mutable_buffer& source, std::size_t max_bytes_to_copy)
+{
+ return buffer_copy(buffer(target, max_bytes_to_copy), source);
+}
+
+/// Copies a limited number of bytes from a source buffer to a target buffer.
+/**
+ * @param target A modifiable buffer representing the memory region to which
+ * the bytes will be copied.
+ *
+ * @param source A modifiable buffer representing the memory region from which
+ * the bytes will be copied. The contents of the source buffer will not be
+ * modified.
+ *
+ * @param max_bytes_to_copy The maximum number of bytes to be copied.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ *
+ * @li @c max_bytes_to_copy
+ */
+inline std::size_t buffer_copy(const mutable_buffer& target,
+ const mutable_buffers_1& source, std::size_t max_bytes_to_copy)
+{
+ return buffer_copy(buffer(target, max_bytes_to_copy), source);
+}
+
+/// Copies a limited number of bytes from a source buffer sequence to a target
+/// buffer.
+/**
+ * @param target A modifiable buffer representing the memory region to which
+ * the bytes will be copied.
+ *
+ * @param source A non-modifiable buffer sequence representing the memory
+ * regions from which the bytes will be copied.
+ *
+ * @param max_bytes_to_copy The maximum number of bytes to be copied.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ *
+ * @li @c max_bytes_to_copy
+ */
+template <typename ConstBufferSequence>
+inline std::size_t buffer_copy(const mutable_buffer& target,
+ const ConstBufferSequence& source, std::size_t max_bytes_to_copy)
+{
+ return buffer_copy(buffer(target, max_bytes_to_copy), source);
+}
+
+/// Copies a limited number of bytes from a source buffer to a target buffer.
+/**
+ * @param target A modifiable buffer representing the memory region to which
+ * the bytes will be copied.
+ *
+ * @param source A non-modifiable buffer representing the memory region from
+ * which the bytes will be copied.
+ *
+ * @param max_bytes_to_copy The maximum number of bytes to be copied.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ *
+ * @li @c max_bytes_to_copy
+ */
+inline std::size_t buffer_copy(const mutable_buffers_1& target,
+ const const_buffer& source, std::size_t max_bytes_to_copy)
+{
+ return buffer_copy(buffer(target, max_bytes_to_copy), source);
+}
+
+/// Copies a limited number of bytes from a source buffer to a target buffer.
+/**
+ * @param target A modifiable buffer representing the memory region to which
+ * the bytes will be copied.
+ *
+ * @param source A non-modifiable buffer representing the memory region from
+ * which the bytes will be copied.
+ *
+ * @param max_bytes_to_copy The maximum number of bytes to be copied.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ *
+ * @li @c max_bytes_to_copy
+ */
+inline std::size_t buffer_copy(const mutable_buffers_1& target,
+ const const_buffers_1& source, std::size_t max_bytes_to_copy)
+{
+ return buffer_copy(buffer(target, max_bytes_to_copy), source);
+}
+
+/// Copies a limited number of bytes from a source buffer to a target buffer.
+/**
+ * @param target A modifiable buffer representing the memory region to which
+ * the bytes will be copied.
+ *
+ * @param source A modifiable buffer representing the memory region from which
+ * the bytes will be copied. The contents of the source buffer will not be
+ * modified.
+ *
+ * @param max_bytes_to_copy The maximum number of bytes to be copied.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ *
+ * @li @c max_bytes_to_copy
+ */
+inline std::size_t buffer_copy(const mutable_buffers_1& target,
+ const mutable_buffer& source, std::size_t max_bytes_to_copy)
+{
+ return buffer_copy(buffer(target, max_bytes_to_copy), source);
+}
+
+/// Copies a limited number of bytes from a source buffer to a target buffer.
+/**
+ * @param target A modifiable buffer representing the memory region to which
+ * the bytes will be copied.
+ *
+ * @param source A modifiable buffer representing the memory region from which
+ * the bytes will be copied. The contents of the source buffer will not be
+ * modified.
+ *
+ * @param max_bytes_to_copy The maximum number of bytes to be copied.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ *
+ * @li @c max_bytes_to_copy
+ */
+inline std::size_t buffer_copy(const mutable_buffers_1& target,
+ const mutable_buffers_1& source, std::size_t max_bytes_to_copy)
+{
+ return buffer_copy(buffer(target, max_bytes_to_copy), source);
+}
+
+/// Copies a limited number of bytes from a source buffer sequence to a target
+/// buffer.
+/**
+ * @param target A modifiable buffer representing the memory region to which
+ * the bytes will be copied.
+ *
+ * @param source A non-modifiable buffer sequence representing the memory
+ * regions from which the bytes will be copied.
+ *
+ * @param max_bytes_to_copy The maximum number of bytes to be copied.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ *
+ * @li @c max_bytes_to_copy
+ */
+template <typename ConstBufferSequence>
+inline std::size_t buffer_copy(const mutable_buffers_1& target,
+ const ConstBufferSequence& source, std::size_t max_bytes_to_copy)
+{
+ return buffer_copy(buffer(target, max_bytes_to_copy), source);
+}
+
+/// Copies a limited number of bytes from a source buffer to a target buffer
+/// sequence.
+/**
+ * @param target A modifiable buffer sequence representing the memory regions to
+ * which the bytes will be copied.
+ *
+ * @param source A non-modifiable buffer representing the memory region from
+ * which the bytes will be copied.
+ *
+ * @param max_bytes_to_copy The maximum number of bytes to be copied.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ *
+ * @li @c max_bytes_to_copy
+ */
+template <typename MutableBufferSequence>
+inline std::size_t buffer_copy(const MutableBufferSequence& target,
+ const const_buffer& source, std::size_t max_bytes_to_copy)
+{
+ return buffer_copy(target, buffer(source, max_bytes_to_copy));
+}
+
+/// Copies a limited number of bytes from a source buffer to a target buffer
+/// sequence.
+/**
+ * @param target A modifiable buffer sequence representing the memory regions to
+ * which the bytes will be copied.
+ *
+ * @param source A non-modifiable buffer representing the memory region from
+ * which the bytes will be copied.
+ *
+ * @param max_bytes_to_copy The maximum number of bytes to be copied.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ *
+ * @li @c max_bytes_to_copy
+ */
+template <typename MutableBufferSequence>
+inline std::size_t buffer_copy(const MutableBufferSequence& target,
+ const const_buffers_1& source, std::size_t max_bytes_to_copy)
+{
+ return buffer_copy(target, buffer(source, max_bytes_to_copy));
+}
+
+/// Copies a limited number of bytes from a source buffer to a target buffer
+/// sequence.
+/**
+ * @param target A modifiable buffer sequence representing the memory regions to
+ * which the bytes will be copied.
+ *
+ * @param source A modifiable buffer representing the memory region from which
+ * the bytes will be copied. The contents of the source buffer will not be
+ * modified.
+ *
+ * @param max_bytes_to_copy The maximum number of bytes to be copied.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ *
+ * @li @c max_bytes_to_copy
+ */
+template <typename MutableBufferSequence>
+inline std::size_t buffer_copy(const MutableBufferSequence& target,
+ const mutable_buffer& source, std::size_t max_bytes_to_copy)
+{
+ return buffer_copy(target, buffer(source, max_bytes_to_copy));
+}
+
+/// Copies a limited number of bytes from a source buffer to a target buffer
+/// sequence.
+/**
+ * @param target A modifiable buffer sequence representing the memory regions to
+ * which the bytes will be copied.
+ *
+ * @param source A modifiable buffer representing the memory region from which
+ * the bytes will be copied. The contents of the source buffer will not be
+ * modified.
+ *
+ * @param max_bytes_to_copy The maximum number of bytes to be copied.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ *
+ * @li @c max_bytes_to_copy
+ */
+template <typename MutableBufferSequence>
+inline std::size_t buffer_copy(const MutableBufferSequence& target,
+ const mutable_buffers_1& source, std::size_t max_bytes_to_copy)
+{
+ return buffer_copy(target, buffer(source, max_bytes_to_copy));
+}
+
+/// Copies a limited number of bytes from a source buffer sequence to a target
+/// buffer sequence.
+/**
+ * @param target A modifiable buffer sequence representing the memory regions to
+ * which the bytes will be copied.
+ *
+ * @param source A non-modifiable buffer sequence representing the memory
+ * regions from which the bytes will be copied.
+ *
+ * @param max_bytes_to_copy The maximum number of bytes to be copied.
+ *
+ * @returns The number of bytes copied.
+ *
+ * @note The number of bytes copied is the lesser of:
+ *
+ * @li @c buffer_size(target)
+ *
+ * @li @c buffer_size(source)
+ *
+ * @li @c max_bytes_to_copy
+ */
+template <typename MutableBufferSequence, typename ConstBufferSequence>
+std::size_t buffer_copy(const MutableBufferSequence& target,
+ const ConstBufferSequence& source, std::size_t max_bytes_to_copy)
+{
+ std::size_t total_bytes_copied = 0;
+
+ typename MutableBufferSequence::const_iterator target_iter = target.begin();
+ typename MutableBufferSequence::const_iterator target_end = target.end();
+ std::size_t target_buffer_offset = 0;
+
+ typename ConstBufferSequence::const_iterator source_iter = source.begin();
+ typename ConstBufferSequence::const_iterator source_end = source.end();
+ std::size_t source_buffer_offset = 0;
+
+ while (total_bytes_copied != max_bytes_to_copy
+ && target_iter != target_end && source_iter != source_end)
+ {
+ mutable_buffer target_buffer =
+ mutable_buffer(*target_iter) + target_buffer_offset;
+
+ const_buffer source_buffer =
+ const_buffer(*source_iter) + source_buffer_offset;
+
+ std::size_t bytes_copied = buffer_copy(target_buffer,
+ source_buffer, max_bytes_to_copy - total_bytes_copied);
+ total_bytes_copied += bytes_copied;
+
+ if (bytes_copied == buffer_size(target_buffer))
+ {
+ ++target_iter;
+ target_buffer_offset = 0;
+ }
+ else
+ target_buffer_offset += bytes_copied;
+
+ if (bytes_copied == buffer_size(source_buffer))
+ {
+ ++source_iter;
+ source_buffer_offset = 0;
+ }
+ else
+ source_buffer_offset += bytes_copied;
+ }
+
+ return total_bytes_copied;
+}
+
+/*@}*/
+
 } // namespace asio
 } // namespace boost
 

Modified: trunk/boost/asio/buffered_read_stream.hpp
==============================================================================
--- trunk/boost/asio/buffered_read_stream.hpp (original)
+++ trunk/boost/asio/buffered_read_stream.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -17,7 +17,6 @@
 
 #include <boost/asio/detail/config.hpp>
 #include <cstddef>
-#include <cstring>
 #include <boost/type_traits/remove_reference.hpp>
 #include <boost/asio/buffered_read_stream_fwd.hpp>
 #include <boost/asio/buffer.hpp>
@@ -97,13 +96,6 @@
     return next_layer_.lowest_layer();
   }
 
- /// (Deprecated: use get_io_service().) Get the io_service associated with
- /// the object.
- boost::asio::io_service& io_service()
- {
- return next_layer_.get_io_service();
- }
-
   /// Get the io_service associated with the object.
   boost::asio::io_service& get_io_service()
   {
@@ -227,16 +219,7 @@
   template <typename MutableBufferSequence>
   std::size_t read_some(const MutableBufferSequence& buffers)
   {
- typename MutableBufferSequence::const_iterator iter = buffers.begin();
- typename MutableBufferSequence::const_iterator end = buffers.end();
- size_t total_buffer_size = 0;
- for (; iter != end; ++iter)
- {
- boost::asio::mutable_buffer buffer(*iter);
- total_buffer_size += boost::asio::buffer_size(buffer);
- }
-
- if (total_buffer_size == 0)
+ if (boost::asio::buffer_size(buffers) == 0)
       return 0;
 
     if (storage_.empty())
@@ -253,16 +236,7 @@
   {
     ec = boost::system::error_code();
 
- typename MutableBufferSequence::const_iterator iter = buffers.begin();
- typename MutableBufferSequence::const_iterator end = buffers.end();
- size_t total_buffer_size = 0;
- for (; iter != end; ++iter)
- {
- boost::asio::mutable_buffer buffer(*iter);
- total_buffer_size += boost::asio::buffer_size(buffer);
- }
-
- if (total_buffer_size == 0)
+ if (boost::asio::buffer_size(buffers) == 0)
       return 0;
 
     if (storage_.empty() && !fill(ec))
@@ -294,24 +268,8 @@
       }
       else
       {
- using namespace std; // For memcpy.
-
- std::size_t bytes_avail = storage_.size();
- std::size_t bytes_copied = 0;
-
- typename MutableBufferSequence::const_iterator iter = buffers_.begin();
- typename MutableBufferSequence::const_iterator end = buffers_.end();
- for (; iter != end && bytes_avail > 0; ++iter)
- {
- std::size_t max_length = buffer_size(*iter);
- std::size_t length = (max_length < bytes_avail)
- ? max_length : bytes_avail;
- memcpy(buffer_cast<void*>(*iter),
- storage_.data() + bytes_copied, length);
- bytes_copied += length;
- bytes_avail -= length;
- }
-
+ std::size_t bytes_copied = boost::asio::buffer_copy(
+ buffers_, storage_.data(), storage_.size());
         storage_.consume(bytes_copied);
         io_service_.dispatch(detail::bind_handler(handler_, ec, bytes_copied));
       }
@@ -330,16 +288,7 @@
   void async_read_some(const MutableBufferSequence& buffers,
       ReadHandler handler)
   {
- typename MutableBufferSequence::const_iterator iter = buffers.begin();
- typename MutableBufferSequence::const_iterator end = buffers.end();
- size_t total_buffer_size = 0;
- for (; iter != end; ++iter)
- {
- boost::asio::mutable_buffer buffer(*iter);
- total_buffer_size += boost::asio::buffer_size(buffer);
- }
-
- if (total_buffer_size == 0)
+ if (boost::asio::buffer_size(buffers) == 0)
     {
       get_io_service().post(detail::bind_handler(
             handler, boost::system::error_code(), 0));
@@ -398,23 +347,8 @@
   template <typename MutableBufferSequence>
   std::size_t copy(const MutableBufferSequence& buffers)
   {
- using namespace std; // For memcpy.
-
- std::size_t bytes_avail = storage_.size();
- std::size_t bytes_copied = 0;
-
- typename MutableBufferSequence::const_iterator iter = buffers.begin();
- typename MutableBufferSequence::const_iterator end = buffers.end();
- for (; iter != end && bytes_avail > 0; ++iter)
- {
- std::size_t max_length = buffer_size(*iter);
- std::size_t length = (max_length < bytes_avail)
- ? max_length : bytes_avail;
- memcpy(buffer_cast<void*>(*iter), storage_.data() + bytes_copied, length);
- bytes_copied += length;
- bytes_avail -= length;
- }
-
+ std::size_t bytes_copied = boost::asio::buffer_copy(
+ buffers, storage_.data(), storage_.size());
     storage_.consume(bytes_copied);
     return bytes_copied;
   }
@@ -425,24 +359,7 @@
   template <typename MutableBufferSequence>
   std::size_t peek_copy(const MutableBufferSequence& buffers)
   {
- using namespace std; // For memcpy.
-
- std::size_t bytes_avail = storage_.size();
- std::size_t bytes_copied = 0;
-
- typename MutableBufferSequence::const_iterator iter = buffers.begin();
- typename MutableBufferSequence::const_iterator end = buffers.end();
- for (; iter != end && bytes_avail > 0; ++iter)
- {
- std::size_t max_length = buffer_size(*iter);
- std::size_t length = (max_length < bytes_avail)
- ? max_length : bytes_avail;
- memcpy(buffer_cast<void*>(*iter), storage_.data() + bytes_copied, length);
- bytes_copied += length;
- bytes_avail -= length;
- }
-
- return bytes_copied;
+ return boost::asio::buffer_copy(buffers, storage_.data(), storage_.size());
   }
 
   /// The next layer.

Modified: trunk/boost/asio/buffered_stream.hpp
==============================================================================
--- trunk/boost/asio/buffered_stream.hpp (original)
+++ trunk/boost/asio/buffered_stream.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -87,13 +87,6 @@
     return stream_impl_.lowest_layer();
   }
 
- /// (Deprecated: use get_io_service().) Get the io_service associated with
- /// the object.
- boost::asio::io_service& io_service()
- {
- return stream_impl_.get_io_service();
- }
-
   /// Get the io_service associated with the object.
   boost::asio::io_service& get_io_service()
   {

Modified: trunk/boost/asio/buffered_write_stream.hpp
==============================================================================
--- trunk/boost/asio/buffered_write_stream.hpp (original)
+++ trunk/boost/asio/buffered_write_stream.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -17,7 +17,6 @@
 
 #include <boost/asio/detail/config.hpp>
 #include <cstddef>
-#include <cstring>
 #include <boost/type_traits/remove_reference.hpp>
 #include <boost/asio/buffered_write_stream_fwd.hpp>
 #include <boost/asio/buffer.hpp>
@@ -98,13 +97,6 @@
     return next_layer_.lowest_layer();
   }
 
- /// (Deprecated: use get_io_service().) Get the io_service associated with
- /// the object.
- boost::asio::io_service& io_service()
- {
- return next_layer_.get_io_service();
- }
-
   /// Get the io_service associated with the object.
   boost::asio::io_service& get_io_service()
   {
@@ -184,16 +176,7 @@
   template <typename ConstBufferSequence>
   std::size_t write_some(const ConstBufferSequence& buffers)
   {
- typename ConstBufferSequence::const_iterator iter = buffers.begin();
- typename ConstBufferSequence::const_iterator end = buffers.end();
- size_t total_buffer_size = 0;
- for (; iter != end; ++iter)
- {
- boost::asio::const_buffer buffer(*iter);
- total_buffer_size += boost::asio::buffer_size(buffer);
- }
-
- if (total_buffer_size == 0)
+ if (boost::asio::buffer_size(buffers) == 0)
       return 0;
 
     if (storage_.size() == storage_.capacity())
@@ -210,16 +193,7 @@
   {
     ec = boost::system::error_code();
 
- typename ConstBufferSequence::const_iterator iter = buffers.begin();
- typename ConstBufferSequence::const_iterator end = buffers.end();
- size_t total_buffer_size = 0;
- for (; iter != end; ++iter)
- {
- boost::asio::const_buffer buffer(*iter);
- total_buffer_size += boost::asio::buffer_size(buffer);
- }
-
- if (total_buffer_size == 0)
+ if (boost::asio::buffer_size(buffers) == 0)
       return 0;
 
     if (storage_.size() == storage_.capacity() && !flush(ec))
@@ -251,25 +225,14 @@
       }
       else
       {
- using namespace std; // For memcpy.
-
         std::size_t orig_size = storage_.size();
         std::size_t space_avail = storage_.capacity() - orig_size;
- std::size_t bytes_copied = 0;
-
- typename ConstBufferSequence::const_iterator iter = buffers_.begin();
- typename ConstBufferSequence::const_iterator end = buffers_.end();
- for (; iter != end && space_avail > 0; ++iter)
- {
- std::size_t bytes_avail = buffer_size(*iter);
- std::size_t length = (bytes_avail < space_avail)
- ? bytes_avail : space_avail;
- storage_.resize(orig_size + bytes_copied + length);
- memcpy(storage_.data() + orig_size + bytes_copied,
- buffer_cast<const void*>(*iter), length);
- bytes_copied += length;
- space_avail -= length;
- }
+ std::size_t bytes_avail = boost::asio::buffer_size(buffers_);
+ std::size_t length = bytes_avail < space_avail
+ ? bytes_avail : space_avail;
+ storage_.resize(orig_size + length);
+ std::size_t bytes_copied = boost::asio::buffer_copy(
+ storage_.data(), buffers_, length);
 
         io_service_.dispatch(detail::bind_handler(handler_, ec, bytes_copied));
       }
@@ -288,16 +251,7 @@
   void async_write_some(const ConstBufferSequence& buffers,
       WriteHandler handler)
   {
- typename ConstBufferSequence::const_iterator iter = buffers.begin();
- typename ConstBufferSequence::const_iterator end = buffers.end();
- size_t total_buffer_size = 0;
- for (; iter != end; ++iter)
- {
- boost::asio::const_buffer buffer(*iter);
- total_buffer_size += boost::asio::buffer_size(buffer);
- }
-
- if (total_buffer_size == 0)
+ if (boost::asio::buffer_size(buffers) == 0)
     {
       get_io_service().post(detail::bind_handler(
             handler, boost::system::error_code(), 0));
@@ -376,27 +330,12 @@
   template <typename ConstBufferSequence>
   std::size_t copy(const ConstBufferSequence& buffers)
   {
- using namespace std; // For memcpy.
-
     std::size_t orig_size = storage_.size();
     std::size_t space_avail = storage_.capacity() - orig_size;
- std::size_t bytes_copied = 0;
-
- typename ConstBufferSequence::const_iterator iter = buffers.begin();
- typename ConstBufferSequence::const_iterator end = buffers.end();
- for (; iter != end && space_avail > 0; ++iter)
- {
- std::size_t bytes_avail = buffer_size(*iter);
- std::size_t length = (bytes_avail < space_avail)
- ? bytes_avail : space_avail;
- storage_.resize(orig_size + bytes_copied + length);
- memcpy(storage_.data() + orig_size + bytes_copied,
- buffer_cast<const void*>(*iter), length);
- bytes_copied += length;
- space_avail -= length;
- }
-
- return bytes_copied;
+ std::size_t bytes_avail = boost::asio::buffer_size(buffers);
+ std::size_t length = bytes_avail < space_avail ? bytes_avail : space_avail;
+ storage_.resize(orig_size + length);
+ return boost::asio::buffer_copy(storage_.data(), buffers, length);
   }
 
   /// The next layer.

Modified: trunk/boost/asio/completion_condition.hpp
==============================================================================
--- trunk/boost/asio/completion_condition.hpp (original)
+++ trunk/boost/asio/completion_condition.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -76,6 +76,28 @@
   std::size_t minimum_;
 };
 
+class transfer_exactly_t
+{
+public:
+ typedef std::size_t result_type;
+
+ explicit transfer_exactly_t(std::size_t size)
+ : size_(size)
+ {
+ }
+
+ template <typename Error>
+ std::size_t operator()(const Error& err, std::size_t bytes_transferred)
+ {
+ return (!!err || bytes_transferred >= size_) ? 0 :
+ (size_ - bytes_transferred < default_max_transfer_size
+ ? size_ - bytes_transferred : std::size_t(default_max_transfer_size));
+ }
+
+private:
+ std::size_t size_;
+};
+
 } // namespace detail
 
 /**
@@ -154,6 +176,40 @@
 }
 #endif
 
+/// Return a completion condition function object that indicates that a read or
+/// write operation should continue until an exact number of bytes has been
+/// transferred, or until an error occurs.
+/**
+ * This function is used to create an object, of unspecified type, that meets
+ * CompletionCondition requirements.
+ *
+ * @par Example
+ * Reading until a buffer is full or contains exactly 64 bytes:
+ * @code
+ * boost::array<char, 128> buf;
+ * boost::system::error_code ec;
+ * std::size_t n = boost::asio::read(
+ * sock, boost::asio::buffer(buf),
+ * boost::asio::transfer_exactly(64), ec);
+ * if (ec)
+ * {
+ * // An error occurred.
+ * }
+ * else
+ * {
+ * // n == 64
+ * }
+ * @endcode
+ */
+#if defined(GENERATING_DOCUMENTATION)
+unspecified transfer_exactly(std::size_t minimum);
+#else
+inline detail::transfer_exactly_t transfer_exactly(std::size_t size)
+{
+ return detail::transfer_exactly_t(size);
+}
+#endif
+
 /*@}*/
 
 } // namespace asio

Added: trunk/boost/asio/connect.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/asio/connect.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -0,0 +1,814 @@
+//
+// connect.hpp
+// ~~~~~~~~~~~
+//
+// 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)
+//
+
+#ifndef BOOST_ASIO_CONNECT_HPP
+#define BOOST_ASIO_CONNECT_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
+
+#include <boost/asio/detail/config.hpp>
+#include <boost/asio/basic_socket.hpp>
+#include <boost/asio/error.hpp>
+
+#include <boost/asio/detail/push_options.hpp>
+
+namespace boost {
+namespace asio {
+
+/**
+ * @defgroup connect boost::asio::connect
+ *
+ * @brief Establishes a socket connection by trying each endpoint in a sequence.
+ */
+/*@{*/
+
+/// Establishes a socket connection by trying each endpoint in a sequence.
+/**
+ * This function attempts to connect a socket to one of a sequence of
+ * endpoints. It does this by repeated calls to the socket's @c connect member
+ * function, once for each endpoint in the sequence, until a connection is
+ * successfully established.
+ *
+ * @param s The socket to be connected. If the socket is already open, it will
+ * be closed.
+ *
+ * @param begin An iterator pointing to the start of a sequence of endpoints.
+ *
+ * @returns On success, an iterator denoting the successfully connected
+ * endpoint. Otherwise, the end iterator.
+ *
+ * @throws boost::system::system_error Thrown on failure. If the sequence is
+ * empty, the associated @c error_code is boost::asio::error::not_found.
+ * Otherwise, contains the error from the last connection attempt.
+ *
+ * @note This overload assumes that a default constructed object of type @c
+ * Iterator represents the end of the sequence. This is a valid assumption for
+ * iterator types such as @c boost::asio::ip::tcp::resolver::iterator.
+ *
+ * @par Example
+ * @code tcp::resolver r(io_service);
+ * tcp::resolver::query q("host", "service");
+ * tcp::socket s(io_service);
+ * boost::asio::connect(s, r.resolve(q)); @endcode
+ */
+template <typename Protocol, typename SocketService, typename Iterator>
+Iterator connect(basic_socket<Protocol, SocketService>& s, Iterator begin);
+
+/// Establishes a socket connection by trying each endpoint in a sequence.
+/**
+ * This function attempts to connect a socket to one of a sequence of
+ * endpoints. It does this by repeated calls to the socket's @c connect member
+ * function, once for each endpoint in the sequence, until a connection is
+ * successfully established.
+ *
+ * @param s The socket to be connected. If the socket is already open, it will
+ * be closed.
+ *
+ * @param begin An iterator pointing to the start of a sequence of endpoints.
+ *
+ * @param ec Set to indicate what error occurred, if any. If the sequence is
+ * empty, set to boost::asio::error::not_found. Otherwise, contains the error
+ * from the last connection attempt.
+ *
+ * @returns On success, an iterator denoting the successfully connected
+ * endpoint. Otherwise, the end iterator.
+ *
+ * @note This overload assumes that a default constructed object of type @c
+ * Iterator represents the end of the sequence. This is a valid assumption for
+ * iterator types such as @c boost::asio::ip::tcp::resolver::iterator.
+ *
+ * @par Example
+ * @code tcp::resolver r(io_service);
+ * tcp::resolver::query q("host", "service");
+ * tcp::socket s(io_service);
+ * boost::system::error_code ec;
+ * boost::asio::connect(s, r.resolve(q), ec);
+ * if (ec)
+ * {
+ * // An error occurred.
+ * } @endcode
+ */
+template <typename Protocol, typename SocketService, typename Iterator>
+Iterator connect(basic_socket<Protocol, SocketService>& s,
+ Iterator begin, boost::system::error_code& ec);
+
+/// Establishes a socket connection by trying each endpoint in a sequence.
+/**
+ * This function attempts to connect a socket to one of a sequence of
+ * endpoints. It does this by repeated calls to the socket's @c connect member
+ * function, once for each endpoint in the sequence, until a connection is
+ * successfully established.
+ *
+ * @param s The socket to be connected. If the socket is already open, it will
+ * be closed.
+ *
+ * @param begin An iterator pointing to the start of a sequence of endpoints.
+ *
+ * @param end An iterator pointing to the end of a sequence of endpoints.
+ *
+ * @returns On success, an iterator denoting the successfully connected
+ * endpoint. Otherwise, the end iterator.
+ *
+ * @throws boost::system::system_error Thrown on failure. If the sequence is
+ * empty, the associated @c error_code is boost::asio::error::not_found.
+ * Otherwise, contains the error from the last connection attempt.
+ *
+ * @par Example
+ * @code tcp::resolver r(io_service);
+ * tcp::resolver::query q("host", "service");
+ * tcp::resolver::iterator i = r.resolve(q), end;
+ * tcp::socket s(io_service);
+ * boost::asio::connect(s, i, end); @endcode
+ */
+template <typename Protocol, typename SocketService, typename Iterator>
+Iterator connect(basic_socket<Protocol, SocketService>& s,
+ Iterator begin, Iterator end);
+
+/// Establishes a socket connection by trying each endpoint in a sequence.
+/**
+ * This function attempts to connect a socket to one of a sequence of
+ * endpoints. It does this by repeated calls to the socket's @c connect member
+ * function, once for each endpoint in the sequence, until a connection is
+ * successfully established.
+ *
+ * @param s The socket to be connected. If the socket is already open, it will
+ * be closed.
+ *
+ * @param begin An iterator pointing to the start of a sequence of endpoints.
+ *
+ * @param end An iterator pointing to the end of a sequence of endpoints.
+ *
+ * @param ec Set to indicate what error occurred, if any. If the sequence is
+ * empty, set to boost::asio::error::not_found. Otherwise, contains the error
+ * from the last connection attempt.
+ *
+ * @returns On success, an iterator denoting the successfully connected
+ * endpoint. Otherwise, the end iterator.
+ *
+ * @par Example
+ * @code tcp::resolver r(io_service);
+ * tcp::resolver::query q("host", "service");
+ * tcp::resolver::iterator i = r.resolve(q), end;
+ * tcp::socket s(io_service);
+ * boost::system::error_code ec;
+ * boost::asio::connect(s, i, end, ec);
+ * if (ec)
+ * {
+ * // An error occurred.
+ * } @endcode
+ */
+template <typename Protocol, typename SocketService, typename Iterator>
+Iterator connect(basic_socket<Protocol, SocketService>& s,
+ Iterator begin, Iterator end, boost::system::error_code& ec);
+
+/// Establishes a socket connection by trying each endpoint in a sequence.
+/**
+ * This function attempts to connect a socket to one of a sequence of
+ * endpoints. It does this by repeated calls to the socket's @c connect member
+ * function, once for each endpoint in the sequence, until a connection is
+ * successfully established.
+ *
+ * @param s The socket to be connected. If the socket is already open, it will
+ * be closed.
+ *
+ * @param begin An iterator pointing to the start of a sequence of endpoints.
+ *
+ * @param connect_condition A function object that is called prior to each
+ * connection attempt. The signature of the function object must be:
+ * @code Iterator connect_condition(
+ * const boost::system::error_code& ec,
+ * Iterator next); @endcode
+ * The @c ec parameter contains the result from the most recent connect
+ * operation. Before the first connection attempt, @c ec is always set to
+ * indicate success. The @c next parameter is an iterator pointing to the next
+ * endpoint to be tried. The function object should return the next iterator,
+ * but is permitted to return a different iterator so that endpoints may be
+ * skipped. The implementation guarantees that the function object will never
+ * be called with the end iterator.
+ *
+ * @returns On success, an iterator denoting the successfully connected
+ * endpoint. Otherwise, the end iterator.
+ *
+ * @throws boost::system::system_error Thrown on failure. If the sequence is
+ * empty, the associated @c error_code is boost::asio::error::not_found.
+ * Otherwise, contains the error from the last connection attempt.
+ *
+ * @note This overload assumes that a default constructed object of type @c
+ * Iterator represents the end of the sequence. This is a valid assumption for
+ * iterator types such as @c boost::asio::ip::tcp::resolver::iterator.
+ *
+ * @par Example
+ * The following connect condition function object can be used to output
+ * information about the individual connection attempts:
+ * @code struct my_connect_condition
+ * {
+ * template <typename Iterator>
+ * Iterator operator()(
+ * const boost::system::error_code& ec,
+ * Iterator next)
+ * {
+ * if (ec) std::cout << "Error: " << ec.message() << std::endl;
+ * std::cout << "Trying: " << next->endpoint() << std::endl;
+ * return next;
+ * }
+ * }; @endcode
+ * It would be used with the boost::asio::connect function as follows:
+ * @code tcp::resolver r(io_service);
+ * tcp::resolver::query q("host", "service");
+ * tcp::socket s(io_service);
+ * tcp::resolver::iterator i = boost::asio::connect(
+ * s, r.resolve(q), my_connect_condition());
+ * std::cout << "Connected to: " << i->endpoint() << std::endl; @endcode
+ */
+template <typename Protocol, typename SocketService,
+ typename Iterator, typename ConnectCondition>
+Iterator connect(basic_socket<Protocol, SocketService>& s,
+ Iterator begin, ConnectCondition connect_condition);
+
+/// Establishes a socket connection by trying each endpoint in a sequence.
+/**
+ * This function attempts to connect a socket to one of a sequence of
+ * endpoints. It does this by repeated calls to the socket's @c connect member
+ * function, once for each endpoint in the sequence, until a connection is
+ * successfully established.
+ *
+ * @param s The socket to be connected. If the socket is already open, it will
+ * be closed.
+ *
+ * @param begin An iterator pointing to the start of a sequence of endpoints.
+ *
+ * @param connect_condition A function object that is called prior to each
+ * connection attempt. The signature of the function object must be:
+ * @code Iterator connect_condition(
+ * const boost::system::error_code& ec,
+ * Iterator next); @endcode
+ * The @c ec parameter contains the result from the most recent connect
+ * operation. Before the first connection attempt, @c ec is always set to
+ * indicate success. The @c next parameter is an iterator pointing to the next
+ * endpoint to be tried. The function object should return the next iterator,
+ * but is permitted to return a different iterator so that endpoints may be
+ * skipped. The implementation guarantees that the function object will never
+ * be called with the end iterator.
+ *
+ * @param ec Set to indicate what error occurred, if any. If the sequence is
+ * empty, set to boost::asio::error::not_found. Otherwise, contains the error
+ * from the last connection attempt.
+ *
+ * @returns On success, an iterator denoting the successfully connected
+ * endpoint. Otherwise, the end iterator.
+ *
+ * @note This overload assumes that a default constructed object of type @c
+ * Iterator represents the end of the sequence. This is a valid assumption for
+ * iterator types such as @c boost::asio::ip::tcp::resolver::iterator.
+ *
+ * @par Example
+ * The following connect condition function object can be used to output
+ * information about the individual connection attempts:
+ * @code struct my_connect_condition
+ * {
+ * template <typename Iterator>
+ * Iterator operator()(
+ * const boost::system::error_code& ec,
+ * Iterator next)
+ * {
+ * if (ec) std::cout << "Error: " << ec.message() << std::endl;
+ * std::cout << "Trying: " << next->endpoint() << std::endl;
+ * return next;
+ * }
+ * }; @endcode
+ * It would be used with the boost::asio::connect function as follows:
+ * @code tcp::resolver r(io_service);
+ * tcp::resolver::query q("host", "service");
+ * tcp::socket s(io_service);
+ * boost::system::error_code ec;
+ * tcp::resolver::iterator i = boost::asio::connect(
+ * s, r.resolve(q), my_connect_condition(), ec);
+ * if (ec)
+ * {
+ * // An error occurred.
+ * }
+ * else
+ * {
+ * std::cout << "Connected to: " << i->endpoint() << std::endl;
+ * } @endcode
+ */
+template <typename Protocol, typename SocketService,
+ typename Iterator, typename ConnectCondition>
+Iterator connect(basic_socket<Protocol, SocketService>& s, Iterator begin,
+ ConnectCondition connect_condition, boost::system::error_code& ec);
+
+/// Establishes a socket connection by trying each endpoint in a sequence.
+/**
+ * This function attempts to connect a socket to one of a sequence of
+ * endpoints. It does this by repeated calls to the socket's @c connect member
+ * function, once for each endpoint in the sequence, until a connection is
+ * successfully established.
+ *
+ * @param s The socket to be connected. If the socket is already open, it will
+ * be closed.
+ *
+ * @param begin An iterator pointing to the start of a sequence of endpoints.
+ *
+ * @param end An iterator pointing to the end of a sequence of endpoints.
+ *
+ * @param connect_condition A function object that is called prior to each
+ * connection attempt. The signature of the function object must be:
+ * @code Iterator connect_condition(
+ * const boost::system::error_code& ec,
+ * Iterator next); @endcode
+ * The @c ec parameter contains the result from the most recent connect
+ * operation. Before the first connection attempt, @c ec is always set to
+ * indicate success. The @c next parameter is an iterator pointing to the next
+ * endpoint to be tried. The function object should return the next iterator,
+ * but is permitted to return a different iterator so that endpoints may be
+ * skipped. The implementation guarantees that the function object will never
+ * be called with the end iterator.
+ *
+ * @returns On success, an iterator denoting the successfully connected
+ * endpoint. Otherwise, the end iterator.
+ *
+ * @throws boost::system::system_error Thrown on failure. If the sequence is
+ * empty, the associated @c error_code is boost::asio::error::not_found.
+ * Otherwise, contains the error from the last connection attempt.
+ *
+ * @par Example
+ * The following connect condition function object can be used to output
+ * information about the individual connection attempts:
+ * @code struct my_connect_condition
+ * {
+ * template <typename Iterator>
+ * Iterator operator()(
+ * const boost::system::error_code& ec,
+ * Iterator next)
+ * {
+ * if (ec) std::cout << "Error: " << ec.message() << std::endl;
+ * std::cout << "Trying: " << next->endpoint() << std::endl;
+ * return next;
+ * }
+ * }; @endcode
+ * It would be used with the boost::asio::connect function as follows:
+ * @code tcp::resolver r(io_service);
+ * tcp::resolver::query q("host", "service");
+ * tcp::resolver::iterator i = r.resolve(q), end;
+ * tcp::socket s(io_service);
+ * i = boost::asio::connect(s, i, end, my_connect_condition());
+ * std::cout << "Connected to: " << i->endpoint() << std::endl; @endcode
+ */
+template <typename Protocol, typename SocketService,
+ typename Iterator, typename ConnectCondition>
+Iterator connect(basic_socket<Protocol, SocketService>& s, Iterator begin,
+ Iterator end, ConnectCondition connect_condition);
+
+/// Establishes a socket connection by trying each endpoint in a sequence.
+/**
+ * This function attempts to connect a socket to one of a sequence of
+ * endpoints. It does this by repeated calls to the socket's @c connect member
+ * function, once for each endpoint in the sequence, until a connection is
+ * successfully established.
+ *
+ * @param s The socket to be connected. If the socket is already open, it will
+ * be closed.
+ *
+ * @param begin An iterator pointing to the start of a sequence of endpoints.
+ *
+ * @param end An iterator pointing to the end of a sequence of endpoints.
+ *
+ * @param connect_condition A function object that is called prior to each
+ * connection attempt. The signature of the function object must be:
+ * @code Iterator connect_condition(
+ * const boost::system::error_code& ec,
+ * Iterator next); @endcode
+ * The @c ec parameter contains the result from the most recent connect
+ * operation. Before the first connection attempt, @c ec is always set to
+ * indicate success. The @c next parameter is an iterator pointing to the next
+ * endpoint to be tried. The function object should return the next iterator,
+ * but is permitted to return a different iterator so that endpoints may be
+ * skipped. The implementation guarantees that the function object will never
+ * be called with the end iterator.
+ *
+ * @param ec Set to indicate what error occurred, if any. If the sequence is
+ * empty, set to boost::asio::error::not_found. Otherwise, contains the error
+ * from the last connection attempt.
+ *
+ * @returns On success, an iterator denoting the successfully connected
+ * endpoint. Otherwise, the end iterator.
+ *
+ * @par Example
+ * The following connect condition function object can be used to output
+ * information about the individual connection attempts:
+ * @code struct my_connect_condition
+ * {
+ * template <typename Iterator>
+ * Iterator operator()(
+ * const boost::system::error_code& ec,
+ * Iterator next)
+ * {
+ * if (ec) std::cout << "Error: " << ec.message() << std::endl;
+ * std::cout << "Trying: " << next->endpoint() << std::endl;
+ * return next;
+ * }
+ * }; @endcode
+ * It would be used with the boost::asio::connect function as follows:
+ * @code tcp::resolver r(io_service);
+ * tcp::resolver::query q("host", "service");
+ * tcp::resolver::iterator i = r.resolve(q), end;
+ * tcp::socket s(io_service);
+ * boost::system::error_code ec;
+ * i = boost::asio::connect(s, i, end, my_connect_condition(), ec);
+ * if (ec)
+ * {
+ * // An error occurred.
+ * }
+ * else
+ * {
+ * std::cout << "Connected to: " << i->endpoint() << std::endl;
+ * } @endcode
+ */
+template <typename Protocol, typename SocketService,
+ typename Iterator, typename ConnectCondition>
+Iterator connect(basic_socket<Protocol, SocketService>& s,
+ Iterator begin, Iterator end, ConnectCondition connect_condition,
+ boost::system::error_code& ec);
+
+/*@}*/
+
+/**
+ * @defgroup async_connect boost::asio::async_connect
+ *
+ * @brief Asynchronously establishes a socket connection by trying each
+ * endpoint in a sequence.
+ */
+/*@{*/
+
+/// Asynchronously establishes a socket connection by trying each endpoint in a
+/// sequence.
+/**
+ * This function attempts to connect a socket to one of a sequence of
+ * endpoints. It does this by repeated calls to the socket's @c async_connect
+ * member function, once for each endpoint in the sequence, until a connection
+ * is successfully established.
+ *
+ * @param s The socket to be connected. If the socket is already open, it will
+ * be closed.
+ *
+ * @param begin An iterator pointing to the start of a sequence of endpoints.
+ *
+ * @param handler The handler to be called when the connect operation
+ * completes. Copies will be made of the handler as required. The function
+ * signature of the handler must be:
+ * @code void handler(
+ * // Result of operation. if the sequence is empty, set to
+ * // boost::asio::error::not_found. Otherwise, contains the
+ * // error from the last connection attempt.
+ * const boost::system::error_code& error,
+ *
+ * // On success, an iterator denoting the successfully
+ * // connected endpoint. Otherwise, the end iterator.
+ * Iterator iterator
+ * ); @endcode
+ * Regardless of whether the asynchronous operation completes immediately or
+ * not, the handler will not be invoked from within this function. Invocation
+ * of the handler will be performed in a manner equivalent to using
+ * boost::asio::io_service::post().
+ *
+ * @note This overload assumes that a default constructed object of type @c
+ * Iterator represents the end of the sequence. This is a valid assumption for
+ * iterator types such as @c boost::asio::ip::tcp::resolver::iterator.
+ *
+ * @par Example
+ * @code tcp::resolver r(io_service);
+ * tcp::resolver::query q("host", "service");
+ * tcp::socket s(io_service);
+ *
+ * // ...
+ *
+ * r.async_resolve(q, resolve_handler);
+ *
+ * // ...
+ *
+ * void resolve_handler(
+ * const boost::system::error_code& ec,
+ * tcp::resolver::iterator i)
+ * {
+ * if (!ec)
+ * {
+ * boost::asio::async_connect(s, i, connect_handler);
+ * }
+ * }
+ *
+ * // ...
+ *
+ * void connect_handler(
+ * const boost::system::error_code& ec,
+ * tcp::resolver::iterator i)
+ * {
+ * // ...
+ * } @endcode
+ */
+template <typename Protocol, typename SocketService,
+ typename Iterator, typename ComposedConnectHandler>
+void async_connect(basic_socket<Protocol, SocketService>& s,
+ Iterator begin, ComposedConnectHandler handler);
+
+/// Asynchronously establishes a socket connection by trying each endpoint in a
+/// sequence.
+/**
+ * This function attempts to connect a socket to one of a sequence of
+ * endpoints. It does this by repeated calls to the socket's @c async_connect
+ * member function, once for each endpoint in the sequence, until a connection
+ * is successfully established.
+ *
+ * @param s The socket to be connected. If the socket is already open, it will
+ * be closed.
+ *
+ * @param begin An iterator pointing to the start of a sequence of endpoints.
+ *
+ * @param end An iterator pointing to the end of a sequence of endpoints.
+ *
+ * @param handler The handler to be called when the connect operation
+ * completes. Copies will be made of the handler as required. The function
+ * signature of the handler must be:
+ * @code void handler(
+ * // Result of operation. if the sequence is empty, set to
+ * // boost::asio::error::not_found. Otherwise, contains the
+ * // error from the last connection attempt.
+ * const boost::system::error_code& error,
+ *
+ * // On success, an iterator denoting the successfully
+ * // connected endpoint. Otherwise, the end iterator.
+ * Iterator iterator
+ * ); @endcode
+ * Regardless of whether the asynchronous operation completes immediately or
+ * not, the handler will not be invoked from within this function. Invocation
+ * of the handler will be performed in a manner equivalent to using
+ * boost::asio::io_service::post().
+ *
+ * @par Example
+ * @code tcp::resolver r(io_service);
+ * tcp::resolver::query q("host", "service");
+ * tcp::socket s(io_service);
+ *
+ * // ...
+ *
+ * r.async_resolve(q, resolve_handler);
+ *
+ * // ...
+ *
+ * void resolve_handler(
+ * const boost::system::error_code& ec,
+ * tcp::resolver::iterator i)
+ * {
+ * if (!ec)
+ * {
+ * tcp::resolver::iterator end;
+ * boost::asio::async_connect(s, i, end, connect_handler);
+ * }
+ * }
+ *
+ * // ...
+ *
+ * void connect_handler(
+ * const boost::system::error_code& ec,
+ * tcp::resolver::iterator i)
+ * {
+ * // ...
+ * } @endcode
+ */
+template <typename Protocol, typename SocketService,
+ typename Iterator, typename ComposedConnectHandler>
+void async_connect(basic_socket<Protocol, SocketService>& s,
+ Iterator begin, Iterator end, ComposedConnectHandler handler);
+
+/// Asynchronously establishes a socket connection by trying each endpoint in a
+/// sequence.
+/**
+ * This function attempts to connect a socket to one of a sequence of
+ * endpoints. It does this by repeated calls to the socket's @c async_connect
+ * member function, once for each endpoint in the sequence, until a connection
+ * is successfully established.
+ *
+ * @param s The socket to be connected. If the socket is already open, it will
+ * be closed.
+ *
+ * @param begin An iterator pointing to the start of a sequence of endpoints.
+ *
+ * @param connect_condition A function object that is called prior to each
+ * connection attempt. The signature of the function object must be:
+ * @code Iterator connect_condition(
+ * const boost::system::error_code& ec,
+ * Iterator next); @endcode
+ * The @c ec parameter contains the result from the most recent connect
+ * operation. Before the first connection attempt, @c ec is always set to
+ * indicate success. The @c next parameter is an iterator pointing to the next
+ * endpoint to be tried. The function object should return the next iterator,
+ * but is permitted to return a different iterator so that endpoints may be
+ * skipped. The implementation guarantees that the function object will never
+ * be called with the end iterator.
+ *
+ * @param handler The handler to be called when the connect operation
+ * completes. Copies will be made of the handler as required. The function
+ * signature of the handler must be:
+ * @code void handler(
+ * // Result of operation. if the sequence is empty, set to
+ * // boost::asio::error::not_found. Otherwise, contains the
+ * // error from the last connection attempt.
+ * const boost::system::error_code& error,
+ *
+ * // On success, an iterator denoting the successfully
+ * // connected endpoint. Otherwise, the end iterator.
+ * Iterator iterator
+ * ); @endcode
+ * Regardless of whether the asynchronous operation completes immediately or
+ * not, the handler will not be invoked from within this function. Invocation
+ * of the handler will be performed in a manner equivalent to using
+ * boost::asio::io_service::post().
+ *
+ * @note This overload assumes that a default constructed object of type @c
+ * Iterator represents the end of the sequence. This is a valid assumption for
+ * iterator types such as @c boost::asio::ip::tcp::resolver::iterator.
+ *
+ * @par Example
+ * The following connect condition function object can be used to output
+ * information about the individual connection attempts:
+ * @code struct my_connect_condition
+ * {
+ * template <typename Iterator>
+ * Iterator operator()(
+ * const boost::system::error_code& ec,
+ * Iterator next)
+ * {
+ * if (ec) std::cout << "Error: " << ec.message() << std::endl;
+ * std::cout << "Trying: " << next->endpoint() << std::endl;
+ * return next;
+ * }
+ * }; @endcode
+ * It would be used with the boost::asio::connect function as follows:
+ * @code tcp::resolver r(io_service);
+ * tcp::resolver::query q("host", "service");
+ * tcp::socket s(io_service);
+ *
+ * // ...
+ *
+ * r.async_resolve(q, resolve_handler);
+ *
+ * // ...
+ *
+ * void resolve_handler(
+ * const boost::system::error_code& ec,
+ * tcp::resolver::iterator i)
+ * {
+ * if (!ec)
+ * {
+ * boost::asio::async_connect(s, i,
+ * my_connect_condition(),
+ * connect_handler);
+ * }
+ * }
+ *
+ * // ...
+ *
+ * void connect_handler(
+ * const boost::system::error_code& ec,
+ * tcp::resolver::iterator i)
+ * {
+ * if (ec)
+ * {
+ * // An error occurred.
+ * }
+ * else
+ * {
+ * std::cout << "Connected to: " << i->endpoint() << std::endl;
+ * }
+ * } @endcode
+ */
+template <typename Protocol, typename SocketService, typename Iterator,
+ typename ConnectCondition, typename ComposedConnectHandler>
+void async_connect(basic_socket<Protocol, SocketService>& s, Iterator begin,
+ ConnectCondition connect_condition, ComposedConnectHandler handler);
+
+/// Asynchronously establishes a socket connection by trying each endpoint in a
+/// sequence.
+/**
+ * This function attempts to connect a socket to one of a sequence of
+ * endpoints. It does this by repeated calls to the socket's @c async_connect
+ * member function, once for each endpoint in the sequence, until a connection
+ * is successfully established.
+ *
+ * @param s The socket to be connected. If the socket is already open, it will
+ * be closed.
+ *
+ * @param begin An iterator pointing to the start of a sequence of endpoints.
+ *
+ * @param end An iterator pointing to the end of a sequence of endpoints.
+ *
+ * @param connect_condition A function object that is called prior to each
+ * connection attempt. The signature of the function object must be:
+ * @code Iterator connect_condition(
+ * const boost::system::error_code& ec,
+ * Iterator next); @endcode
+ * The @c ec parameter contains the result from the most recent connect
+ * operation. Before the first connection attempt, @c ec is always set to
+ * indicate success. The @c next parameter is an iterator pointing to the next
+ * endpoint to be tried. The function object should return the next iterator,
+ * but is permitted to return a different iterator so that endpoints may be
+ * skipped. The implementation guarantees that the function object will never
+ * be called with the end iterator.
+ *
+ * @param handler The handler to be called when the connect operation
+ * completes. Copies will be made of the handler as required. The function
+ * signature of the handler must be:
+ * @code void handler(
+ * // Result of operation. if the sequence is empty, set to
+ * // boost::asio::error::not_found. Otherwise, contains the
+ * // error from the last connection attempt.
+ * const boost::system::error_code& error,
+ *
+ * // On success, an iterator denoting the successfully
+ * // connected endpoint. Otherwise, the end iterator.
+ * Iterator iterator
+ * ); @endcode
+ * Regardless of whether the asynchronous operation completes immediately or
+ * not, the handler will not be invoked from within this function. Invocation
+ * of the handler will be performed in a manner equivalent to using
+ * boost::asio::io_service::post().
+ *
+ * @par Example
+ * The following connect condition function object can be used to output
+ * information about the individual connection attempts:
+ * @code struct my_connect_condition
+ * {
+ * template <typename Iterator>
+ * Iterator operator()(
+ * const boost::system::error_code& ec,
+ * Iterator next)
+ * {
+ * if (ec) std::cout << "Error: " << ec.message() << std::endl;
+ * std::cout << "Trying: " << next->endpoint() << std::endl;
+ * return next;
+ * }
+ * }; @endcode
+ * It would be used with the boost::asio::connect function as follows:
+ * @code tcp::resolver r(io_service);
+ * tcp::resolver::query q("host", "service");
+ * tcp::socket s(io_service);
+ *
+ * // ...
+ *
+ * r.async_resolve(q, resolve_handler);
+ *
+ * // ...
+ *
+ * void resolve_handler(
+ * const boost::system::error_code& ec,
+ * tcp::resolver::iterator i)
+ * {
+ * if (!ec)
+ * {
+ * tcp::resolver::iterator end;
+ * boost::asio::async_connect(s, i, end,
+ * my_connect_condition(),
+ * connect_handler);
+ * }
+ * }
+ *
+ * // ...
+ *
+ * void connect_handler(
+ * const boost::system::error_code& ec,
+ * tcp::resolver::iterator i)
+ * {
+ * if (ec)
+ * {
+ * // An error occurred.
+ * }
+ * else
+ * {
+ * std::cout << "Connected to: " << i->endpoint() << std::endl;
+ * }
+ * } @endcode
+ */
+template <typename Protocol, typename SocketService, typename Iterator,
+ typename ConnectCondition, typename ComposedConnectHandler>
+void async_connect(basic_socket<Protocol, SocketService>& s,
+ Iterator begin, Iterator end, ConnectCondition connect_condition,
+ ComposedConnectHandler handler);
+
+/*@}*/
+
+} // namespace asio
+} // namespace boost
+
+#include <boost/asio/detail/pop_options.hpp>
+
+#include <boost/asio/impl/connect.hpp>
+
+#endif

Modified: trunk/boost/asio/datagram_socket_service.hpp
==============================================================================
--- trunk/boost/asio/datagram_socket_service.hpp (original)
+++ trunk/boost/asio/datagram_socket_service.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -68,11 +68,18 @@
   typedef typename service_impl_type::implementation_type implementation_type;
 #endif
 
- /// The native socket type.
+ /// (Deprecated: Use native_handle_type.) The native socket type.
 #if defined(GENERATING_DOCUMENTATION)
   typedef implementation_defined native_type;
 #else
- typedef typename service_impl_type::native_type native_type;
+ typedef typename service_impl_type::native_handle_type native_type;
+#endif
+
+ /// The native socket type.
+#if defined(GENERATING_DOCUMENTATION)
+ typedef implementation_defined native_handle_type;
+#else
+ typedef typename service_impl_type::native_handle_type native_handle_type;
 #endif
 
   /// Construct a new datagram socket service for the specified io_service.
@@ -114,7 +121,7 @@
 
   /// Assign an existing native socket to a datagram socket.
   boost::system::error_code assign(implementation_type& impl,
- const protocol_type& protocol, const native_type& native_socket,
+ const protocol_type& protocol, const native_handle_type& native_socket,
       boost::system::error_code& ec)
   {
     return service_impl_.assign(impl, protocol, native_socket, ec);
@@ -133,10 +140,16 @@
     return service_impl_.close(impl, ec);
   }
 
- /// Get the native socket implementation.
+ /// (Deprecated: Use native_handle().) Get the native socket implementation.
   native_type native(implementation_type& impl)
   {
- return service_impl_.native(impl);
+ return service_impl_.native_handle(impl);
+ }
+
+ /// Get the native socket implementation.
+ native_handle_type native_handle(implementation_type& impl)
+ {
+ return service_impl_.native_handle(impl);
   }
 
   /// Cancel all asynchronous operations associated with the socket.
@@ -206,6 +219,32 @@
     return service_impl_.io_control(impl, command, ec);
   }
 
+ /// Gets the non-blocking mode of the socket.
+ bool non_blocking(const implementation_type& impl) const
+ {
+ return service_impl_.non_blocking(impl);
+ }
+
+ /// Sets the non-blocking mode of the socket.
+ boost::system::error_code non_blocking(implementation_type& impl,
+ bool mode, boost::system::error_code& ec)
+ {
+ return service_impl_.non_blocking(impl, mode, ec);
+ }
+
+ /// Gets the non-blocking mode of the native socket implementation.
+ bool native_non_blocking(const implementation_type& impl) const
+ {
+ return service_impl_.native_non_blocking(impl);
+ }
+
+ /// Sets the non-blocking mode of the native socket implementation.
+ boost::system::error_code native_non_blocking(implementation_type& impl,
+ bool mode, boost::system::error_code& ec)
+ {
+ return service_impl_.native_non_blocking(impl, mode, ec);
+ }
+
   /// Get the local endpoint.
   endpoint_type local_endpoint(const implementation_type& impl,
       boost::system::error_code& ec) const

Modified: trunk/boost/asio/deadline_timer_service.hpp
==============================================================================
--- trunk/boost/asio/deadline_timer_service.hpp (original)
+++ trunk/boost/asio/deadline_timer_service.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -96,6 +96,13 @@
     return service_impl_.cancel(impl, ec);
   }
 
+ /// Cancels one asynchronous wait operation associated with the timer.
+ std::size_t cancel_one(implementation_type& impl,
+ boost::system::error_code& ec)
+ {
+ return service_impl_.cancel_one(impl, ec);
+ }
+
   /// Get the expiry time for the timer as an absolute time.
   time_type expires_at(const implementation_type& impl) const
   {

Modified: trunk/boost/asio/detail/bind_handler.hpp
==============================================================================
--- trunk/boost/asio/detail/bind_handler.hpp (original)
+++ trunk/boost/asio/detail/bind_handler.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -35,6 +35,12 @@
   {
   }
 
+ binder1(Handler& handler, const Arg1& arg1)
+ : handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)),
+ arg1_(arg1)
+ {
+ }
+
   void operator()()
   {
     handler_(static_cast<const Arg1&>(arg1_));
@@ -92,6 +98,13 @@
   {
   }
 
+ binder2(Handler& handler, const Arg1& arg1, const Arg2& arg2)
+ : handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)),
+ arg1_(arg1),
+ arg2_(arg2)
+ {
+ }
+
   void operator()()
   {
     handler_(static_cast<const Arg1&>(arg1_),
@@ -153,6 +166,15 @@
   {
   }
 
+ binder3(Handler& handler, const Arg1& arg1, const Arg2& arg2,
+ const Arg3& arg3)
+ : handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)),
+ arg1_(arg1),
+ arg2_(arg2),
+ arg3_(arg3)
+ {
+ }
+
   void operator()()
   {
     handler_(static_cast<const Arg1&>(arg1_),
@@ -219,6 +241,16 @@
   {
   }
 
+ binder4(Handler& handler, const Arg1& arg1, const Arg2& arg2,
+ const Arg3& arg3, const Arg4& arg4)
+ : handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)),
+ arg1_(arg1),
+ arg2_(arg2),
+ arg3_(arg3),
+ arg4_(arg4)
+ {
+ }
+
   void operator()()
   {
     handler_(static_cast<const Arg1&>(arg1_),
@@ -293,6 +325,17 @@
   {
   }
 
+ binder5(Handler& handler, const Arg1& arg1, const Arg2& arg2,
+ const Arg3& arg3, const Arg4& arg4, const Arg5& arg5)
+ : handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)),
+ arg1_(arg1),
+ arg2_(arg2),
+ arg3_(arg3),
+ arg4_(arg4),
+ arg5_(arg5)
+ {
+ }
+
   void operator()()
   {
     handler_(static_cast<const Arg1&>(arg1_),

Modified: trunk/boost/asio/detail/buffer_sequence_adapter.hpp
==============================================================================
--- trunk/boost/asio/detail/buffer_sequence_adapter.hpp (original)
+++ trunk/boost/asio/detail/buffer_sequence_adapter.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -81,11 +81,11 @@
   : buffer_sequence_adapter_base
 {
 public:
- explicit buffer_sequence_adapter(const Buffers& buffers)
+ explicit buffer_sequence_adapter(const Buffers& buffer_sequence)
     : count_(0), total_buffer_size_(0)
   {
- typename Buffers::const_iterator iter = buffers.begin();
- typename Buffers::const_iterator end = buffers.end();
+ typename Buffers::const_iterator iter = buffer_sequence.begin();
+ typename Buffers::const_iterator end = buffer_sequence.end();
     for (; iter != end && count_ < max_buffers; ++iter, ++count_)
     {
       Buffer buffer(*iter);
@@ -109,10 +109,10 @@
     return total_buffer_size_ == 0;
   }
 
- static bool all_empty(const Buffers& buffers)
+ static bool all_empty(const Buffers& buffer_sequence)
   {
- typename Buffers::const_iterator iter = buffers.begin();
- typename Buffers::const_iterator end = buffers.end();
+ typename Buffers::const_iterator iter = buffer_sequence.begin();
+ typename Buffers::const_iterator end = buffer_sequence.end();
     std::size_t i = 0;
     for (; iter != end && i < max_buffers; ++iter, ++i)
       if (boost::asio::buffer_size(Buffer(*iter)) > 0)
@@ -120,10 +120,10 @@
     return true;
   }
 
- static void validate(const Buffers& buffers)
+ static void validate(const Buffers& buffer_sequence)
   {
- typename Buffers::const_iterator iter = buffers.begin();
- typename Buffers::const_iterator end = buffers.end();
+ typename Buffers::const_iterator iter = buffer_sequence.begin();
+ typename Buffers::const_iterator end = buffer_sequence.end();
     for (; iter != end; ++iter)
     {
       Buffer buffer(*iter);
@@ -131,10 +131,10 @@
     }
   }
 
- static Buffer first(const Buffers& buffers)
+ static Buffer first(const Buffers& buffer_sequence)
   {
- typename Buffers::const_iterator iter = buffers.begin();
- typename Buffers::const_iterator end = buffers.end();
+ typename Buffers::const_iterator iter = buffer_sequence.begin();
+ typename Buffers::const_iterator end = buffer_sequence.end();
     for (; iter != end; ++iter)
     {
       Buffer buffer(*iter);
@@ -159,10 +159,10 @@
 {
 public:
   explicit buffer_sequence_adapter(
- const boost::asio::mutable_buffers_1& buffers)
+ const boost::asio::mutable_buffers_1& buffer_sequence)
   {
- init_native_buffer(buffer_, Buffer(buffers));
- total_buffer_size_ = boost::asio::buffer_size(buffers);
+ init_native_buffer(buffer_, Buffer(buffer_sequence));
+ total_buffer_size_ = boost::asio::buffer_size(buffer_sequence);
   }
 
   native_buffer_type* buffers()
@@ -180,19 +180,19 @@
     return total_buffer_size_ == 0;
   }
 
- static bool all_empty(const boost::asio::mutable_buffers_1& buffers)
+ static bool all_empty(const boost::asio::mutable_buffers_1& buffer_sequence)
   {
- return boost::asio::buffer_size(buffers) == 0;
+ return boost::asio::buffer_size(buffer_sequence) == 0;
   }
 
- static void validate(const boost::asio::mutable_buffers_1& buffers)
+ static void validate(const boost::asio::mutable_buffers_1& buffer_sequence)
   {
- boost::asio::buffer_cast<const void*>(buffers);
+ boost::asio::buffer_cast<const void*>(buffer_sequence);
   }
 
- static Buffer first(const boost::asio::mutable_buffers_1& buffers)
+ static Buffer first(const boost::asio::mutable_buffers_1& buffer_sequence)
   {
- return Buffer(buffers);
+ return Buffer(buffer_sequence);
   }
 
 private:
@@ -206,10 +206,10 @@
 {
 public:
   explicit buffer_sequence_adapter(
- const boost::asio::const_buffers_1& buffers)
+ const boost::asio::const_buffers_1& buffer_sequence)
   {
- init_native_buffer(buffer_, Buffer(buffers));
- total_buffer_size_ = boost::asio::buffer_size(buffers);
+ init_native_buffer(buffer_, Buffer(buffer_sequence));
+ total_buffer_size_ = boost::asio::buffer_size(buffer_sequence);
   }
 
   native_buffer_type* buffers()
@@ -227,19 +227,19 @@
     return total_buffer_size_ == 0;
   }
 
- static bool all_empty(const boost::asio::const_buffers_1& buffers)
+ static bool all_empty(const boost::asio::const_buffers_1& buffer_sequence)
   {
- return boost::asio::buffer_size(buffers) == 0;
+ return boost::asio::buffer_size(buffer_sequence) == 0;
   }
 
- static void validate(const boost::asio::const_buffers_1& buffers)
+ static void validate(const boost::asio::const_buffers_1& buffer_sequence)
   {
- boost::asio::buffer_cast<const void*>(buffers);
+ boost::asio::buffer_cast<const void*>(buffer_sequence);
   }
 
- static Buffer first(const boost::asio::const_buffers_1& buffers)
+ static Buffer first(const boost::asio::const_buffers_1& buffer_sequence)
   {
- return Buffer(buffers);
+ return Buffer(buffer_sequence);
   }
 
 private:

Modified: trunk/boost/asio/detail/buffered_stream_storage.hpp
==============================================================================
--- trunk/boost/asio/detail/buffered_stream_storage.hpp (original)
+++ trunk/boost/asio/detail/buffered_stream_storage.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -16,7 +16,8 @@
 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
 
 #include <boost/asio/detail/config.hpp>
-#include <cassert>
+#include <boost/asio/buffer.hpp>
+#include <boost/assert.hpp>
 #include <cstddef>
 #include <cstring>
 #include <vector>
@@ -37,10 +38,10 @@
   typedef std::size_t size_type;
 
   // Constructor.
- explicit buffered_stream_storage(std::size_t capacity)
+ explicit buffered_stream_storage(std::size_t buffer_capacity)
     : begin_offset_(0),
       end_offset_(0),
- buffer_(capacity)
+ buffer_(buffer_capacity)
   {
   }
 
@@ -52,15 +53,15 @@
   }
 
   // Return a pointer to the beginning of the unread data.
- byte_type* data()
+ mutable_buffer data()
   {
- return &buffer_[0] + begin_offset_;
+ return boost::asio::buffer(buffer_) + begin_offset_;
   }
 
   // Return a pointer to the beginning of the unread data.
- const byte_type* data() const
+ const_buffer data() const
   {
- return &buffer_[0] + begin_offset_;
+ return boost::asio::buffer(buffer_) + begin_offset_;
   }
 
   // Is there no unread data in the buffer.
@@ -78,7 +79,7 @@
   // Resize the buffer to the specified length.
   void resize(size_type length)
   {
- assert(length <= capacity());
+ BOOST_ASSERT(length <= capacity());
     if (begin_offset_ + length <= capacity())
     {
       end_offset_ = begin_offset_ + length;
@@ -101,7 +102,7 @@
   // Consume multiple bytes from the beginning of the buffer.
   void consume(size_type count)
   {
- assert(begin_offset_ + count <= end_offset_);
+ BOOST_ASSERT(begin_offset_ + count <= end_offset_);
     begin_offset_ += count;
     if (empty())
       clear();

Modified: trunk/boost/asio/detail/completion_handler.hpp
==============================================================================
--- trunk/boost/asio/detail/completion_handler.hpp (original)
+++ trunk/boost/asio/detail/completion_handler.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -33,9 +33,9 @@
 public:
   BOOST_ASIO_DEFINE_HANDLER_PTR(completion_handler);
 
- completion_handler(Handler h)
+ completion_handler(Handler& h)
     : operation(&completion_handler::do_complete),
- handler_(h)
+ handler_(BOOST_ASIO_MOVE_CAST(Handler)(h))
   {
   }
 
@@ -52,7 +52,7 @@
     // with the handler. Consequently, a local copy of the handler is required
     // to ensure that any owning sub-object remains valid until after we have
     // deallocated the memory here.
- Handler handler(h->handler_);
+ Handler handler(BOOST_ASIO_MOVE_CAST(Handler)(h->handler_));
     p.h = boost::addressof(handler);
     p.reset();
 

Modified: trunk/boost/asio/detail/config.hpp
==============================================================================
--- trunk/boost/asio/detail/config.hpp (original)
+++ trunk/boost/asio/detail/config.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -46,6 +46,41 @@
 # define BOOST_ASIO_DECL
 #endif // !defined(BOOST_ASIO_DECL)
 
+// Support move construction on compilers known to allow it.
+#if defined(__GNUC__)
+# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
+# if defined(__GXX_EXPERIMENTAL_CXX0X__)
+# 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__)
+#if defined(BOOST_MSVC)
+# if (_MSC_VER >= 1600)
+# define BOOST_ASIO_MOVE_CAST(type) static_cast<type&&>
+# endif // (_MSC_VER >= 1600)
+#endif // defined(BOOST_MSVC)
+
+// If BOOST_ASIO_MOVE_CAST isn't defined yet use a C++03 compatible version.
+#if !defined(BOOST_ASIO_MOVE_CAST)
+# define BOOST_ASIO_MOVE_CAST(type) static_cast<const type&>
+#endif // !defined_BOOST_ASIO_MOVE_CAST
+
+// Standard library support for system errors.
+#if !defined(BOOST_ASIO_DISABLE_STD_SYSTEM_ERROR)
+# if defined(__GNUC__)
+# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
+# if defined(__GXX_EXPERIMENTAL_CXX0X__)
+# define BOOST_ASIO_HAS_STD_SYSTEM_ERROR
+# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
+# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
+# endif // defined(__GNUC__)
+# if defined(BOOST_MSVC)
+# if (_MSC_VER >= 1600)
+# define BOOST_ASIO_HAS_STD_SYSTEM_ERROR
+# endif // (_MSC_VER >= 1600)
+# endif // defined(BOOST_MSVC)
+#endif // !defined(BOOST_ASIO_DISABLE_STD_SYSTEM_ERROR)
+
 // Windows: target OS version.
 #if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
 # if !defined(_WIN32_WINNT) && !defined(_WIN32_WINDOWS)

Modified: trunk/boost/asio/detail/deadline_timer_service.hpp
==============================================================================
--- trunk/boost/asio/detail/deadline_timer_service.hpp (original)
+++ trunk/boost/asio/detail/deadline_timer_service.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -100,12 +100,31 @@
       ec = boost::system::error_code();
       return 0;
     }
+
     std::size_t count = scheduler_.cancel_timer(timer_queue_, impl.timer_data);
     impl.might_have_pending_waits = false;
     ec = boost::system::error_code();
     return count;
   }
 
+ // Cancels one asynchronous wait operation associated with the timer.
+ std::size_t cancel_one(implementation_type& impl,
+ boost::system::error_code& ec)
+ {
+ if (!impl.might_have_pending_waits)
+ {
+ ec = boost::system::error_code();
+ return 0;
+ }
+
+ std::size_t count = scheduler_.cancel_timer(
+ timer_queue_, impl.timer_data, 1);
+ if (count == 0)
+ impl.might_have_pending_waits = false;
+ ec = boost::system::error_code();
+ return count;
+ }
+
   // Get the expiry time for the timer as an absolute time.
   time_type expires_at(const implementation_type& impl) const
   {
@@ -140,23 +159,22 @@
   void wait(implementation_type& impl, boost::system::error_code& ec)
   {
     time_type now = Time_Traits::now();
- while (Time_Traits::less_than(now, impl.expiry))
+ ec = boost::system::error_code();
+ while (Time_Traits::less_than(now, impl.expiry) && !ec)
     {
       boost::posix_time::time_duration timeout =
         Time_Traits::to_posix_duration(Time_Traits::subtract(impl.expiry, now));
       ::timeval tv;
       tv.tv_sec = timeout.total_seconds();
       tv.tv_usec = timeout.total_microseconds() % 1000000;
- boost::system::error_code ec;
       socket_ops::select(0, 0, 0, 0, &tv, ec);
       now = Time_Traits::now();
     }
- ec = boost::system::error_code();
   }
 
   // Start an asynchronous wait on the timer.
   template <typename Handler>
- void async_wait(implementation_type& impl, Handler handler)
+ void async_wait(implementation_type& impl, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef wait_handler<Handler> op;

Modified: trunk/boost/asio/detail/descriptor_ops.hpp
==============================================================================
--- trunk/boost/asio/detail/descriptor_ops.hpp (original)
+++ trunk/boost/asio/detail/descriptor_ops.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -40,7 +40,10 @@
   internal_non_blocking = 2,
 
   // Helper "state" used to determine whether the descriptor is non-blocking.
- non_blocking = user_set_non_blocking | internal_non_blocking
+ non_blocking = user_set_non_blocking | internal_non_blocking,
+
+ // The descriptor may have been dup()-ed.
+ possible_dup = 4
 };
 
 typedef unsigned char state_type;
@@ -60,8 +63,11 @@
 BOOST_ASIO_DECL int close(int d, state_type& state,
     boost::system::error_code& ec);
 
+BOOST_ASIO_DECL bool set_user_non_blocking(int d,
+ state_type& state, bool value, boost::system::error_code& ec);
+
 BOOST_ASIO_DECL bool set_internal_non_blocking(int d,
- state_type& state, boost::system::error_code& ec);
+ state_type& state, bool value, boost::system::error_code& ec);
 
 typedef iovec buf;
 

Modified: trunk/boost/asio/detail/descriptor_read_op.hpp
==============================================================================
--- trunk/boost/asio/detail/descriptor_read_op.hpp (original)
+++ trunk/boost/asio/detail/descriptor_read_op.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -68,10 +68,10 @@
   BOOST_ASIO_DEFINE_HANDLER_PTR(descriptor_read_op);
 
   descriptor_read_op(int descriptor,
- const MutableBufferSequence& buffers, Handler handler)
+ const MutableBufferSequence& buffers, Handler& handler)
     : descriptor_read_op_base<MutableBufferSequence>(
         descriptor, buffers, &descriptor_read_op::do_complete),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler))
   {
   }
 

Modified: trunk/boost/asio/detail/descriptor_write_op.hpp
==============================================================================
--- trunk/boost/asio/detail/descriptor_write_op.hpp (original)
+++ trunk/boost/asio/detail/descriptor_write_op.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -68,10 +68,10 @@
   BOOST_ASIO_DEFINE_HANDLER_PTR(descriptor_write_op);
 
   descriptor_write_op(int descriptor,
- const ConstBufferSequence& buffers, Handler handler)
+ const ConstBufferSequence& buffers, Handler& handler)
     : descriptor_write_op_base<ConstBufferSequence>(
         descriptor, buffers, &descriptor_write_op::do_complete),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler))
   {
   }
 

Modified: trunk/boost/asio/detail/dev_poll_reactor.hpp
==============================================================================
--- trunk/boost/asio/detail/dev_poll_reactor.hpp (original)
+++ trunk/boost/asio/detail/dev_poll_reactor.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -19,6 +19,7 @@
 
 #if defined(BOOST_ASIO_HAS_DEV_POLL)
 
+#include <boost/limits.hpp>
 #include <cstddef>
 #include <vector>
 #include <sys/devpoll.h>
@@ -46,7 +47,7 @@
   : public boost::asio::detail::service_base<dev_poll_reactor>
 {
 public:
- enum { read_op = 0, write_op = 1,
+ enum op_types { read_op = 0, write_op = 1,
     connect_op = 1, except_op = 2, max_ops = 3 };
 
   // Per-descriptor data.
@@ -88,8 +89,8 @@
 
   // Cancel any operations that are running against the descriptor and remove
   // its registration from the reactor.
- BOOST_ASIO_DECL void close_descriptor(
- socket_type descriptor, per_descriptor_data&);
+ BOOST_ASIO_DECL void deregister_descriptor(socket_type descriptor,
+ per_descriptor_data&, bool closing);
 
   // Add a new timer queue to the reactor.
   template <typename Time_Traits>
@@ -110,7 +111,8 @@
   // number of operations that have been posted or dispatched.
   template <typename Time_Traits>
   std::size_t cancel_timer(timer_queue<Time_Traits>& queue,
- typename timer_queue<Time_Traits>::per_timer_data& timer);
+ typename timer_queue<Time_Traits>::per_timer_data& timer,
+ std::size_t max_cancelled = (std::numeric_limits<std::size_t>::max)());
 
   // Run /dev/poll once until interrupted or events are ready to be dispatched.
   BOOST_ASIO_DECL void run(bool block, op_queue<operation>& ops);

Modified: trunk/boost/asio/detail/epoll_reactor.hpp
==============================================================================
--- trunk/boost/asio/detail/epoll_reactor.hpp (original)
+++ trunk/boost/asio/detail/epoll_reactor.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -19,6 +19,7 @@
 
 #if defined(BOOST_ASIO_HAS_EPOLL)
 
+#include <boost/limits.hpp>
 #include <boost/asio/io_service.hpp>
 #include <boost/asio/detail/epoll_reactor_fwd.hpp>
 #include <boost/asio/detail/mutex.hpp>
@@ -42,7 +43,7 @@
   : public boost::asio::detail::service_base<epoll_reactor>
 {
 public:
- enum { read_op = 0, write_op = 1,
+ enum op_types { read_op = 0, write_op = 1,
     connect_op = 1, except_op = 2, max_ops = 3 };
 
   // Per-descriptor queues.
@@ -97,8 +98,8 @@
 
   // Cancel any operations that are running against the descriptor and remove
   // its registration from the reactor.
- BOOST_ASIO_DECL void close_descriptor(socket_type descriptor,
- per_descriptor_data& descriptor_data);
+ BOOST_ASIO_DECL void deregister_descriptor(socket_type descriptor,
+ per_descriptor_data& descriptor_data, bool closing);
 
   // Add a new timer queue to the reactor.
   template <typename Time_Traits>
@@ -119,7 +120,8 @@
   // number of operations that have been posted or dispatched.
   template <typename Time_Traits>
   std::size_t cancel_timer(timer_queue<Time_Traits>& queue,
- typename timer_queue<Time_Traits>::per_timer_data& timer);
+ typename timer_queue<Time_Traits>::per_timer_data& timer,
+ std::size_t max_cancelled = (std::numeric_limits<std::size_t>::max)());
 
   // Run epoll once until interrupted or events are ready to be dispatched.
   BOOST_ASIO_DECL void run(bool block, op_queue<operation>& ops);

Added: trunk/boost/asio/detail/handler_type_requirements.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/asio/detail/handler_type_requirements.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -0,0 +1,288 @@
+//
+// detail/handler_type_requirements.hpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// 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)
+//
+
+#ifndef BOOST_ASIO_DETAIL_HANDLER_TYPE_REQUIREMENTS_HPP
+#define BOOST_ASIO_DETAIL_HANDLER_TYPE_REQUIREMENTS_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
+
+#include <boost/asio/detail/config.hpp>
+
+namespace boost {
+namespace asio {
+namespace detail {
+
+// Older versions of gcc have difficulty compiling the sizeof expressions where
+// we test the handler type requirements. We'll disable checking of handler type
+// requirements for those compilers, but otherwise enable it by default.
+#if !defined(BOOST_ASIO_DISABLE_HANDLER_TYPE_REQUIREMENTS)
+# if !defined(__GNUC__) || (__GNUC__ >= 4)
+# define BOOST_ASIO_ENABLE_HANDLER_TYPE_REQUIREMENTS 1
+# endif // !defined(__GNUC__) || (__GNUC__ >= 4)
+#endif // !defined(BOOST_ASIO_DISABLE_HANDLER_TYPE_REQUIREMENTS)
+
+// With C++0x we can use a combination of enhanced SFINAE and static_assert to
+// generate better template error messages. As this technique is not yet widely
+// portable, we'll only enable it for tested compilers.
+#if !defined(BOOST_ASIO_DISABLE_HANDLER_TYPE_REQUIREMENTS_ASSERT)
+# if defined(__GNUC__)
+# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
+# if defined(__GXX_EXPERIMENTAL_CXX0X__)
+# define BOOST_ASIO_ENABLE_HANDLER_TYPE_REQUIREMENTS_ASSERT 1
+# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
+# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4)
+# endif // defined(__GNUC__)
+# if defined(BOOST_MSVC)
+# if (_MSC_VER >= 1600)
+# define BOOST_ASIO_ENABLE_HANDLER_TYPE_REQUIREMENTS_ASSERT 1
+# endif // (_MSC_VER >= 1600)
+# endif // defined(BOOST_MSVC)
+#endif // !defined(BOOST_ASIO_DISABLE_HANDLER_TYPE_REQUIREMENTS)
+
+#if defined(BOOST_ASIO_ENABLE_HANDLER_TYPE_REQUIREMENTS)
+
+# if defined(BOOST_ASIO_ENABLE_HANDLER_TYPE_REQUIREMENTS_ASSERT)
+
+template <typename Handler>
+auto zero_arg_handler_test(Handler* h)
+ -> decltype(
+ sizeof(Handler(*static_cast<const Handler*>(h))),
+ ((*h)()),
+ char(0));
+
+char (&zero_arg_handler_test(...))[2];
+
+template <typename Handler, typename Arg1>
+auto one_arg_handler_test(Handler* h, Arg1* a1)
+ -> decltype(
+ sizeof(Handler(*static_cast<const Handler*>(h))),
+ ((*h)(*a1)),
+ char(0));
+
+char (&one_arg_handler_test(...))[2];
+
+template <typename Handler, typename Arg1, typename Arg2>
+auto two_arg_handler_test(Handler* h, Arg1* a1, Arg2* a2)
+ -> decltype(
+ sizeof(Handler(*static_cast<const Handler*>(h))),
+ ((*h)(*a1, *a2)),
+ char(0));
+
+char (&two_arg_handler_test(...))[2];
+
+# define BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT(expr, msg) \
+ static_assert(expr, msg);
+
+# else // defined(BOOST_ASIO_ENABLE_HANDLER_TYPE_REQUIREMENTS_ASSERT)
+
+# define BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT(expr, msg)
+
+# endif // defined(BOOST_ASIO_ENABLE_HANDLER_TYPE_REQUIREMENTS_ASSERT)
+
+template <typename T> T& lvref();
+
+template <int>
+struct handler_type_requirements
+{
+};
+
+#define BOOST_ASIO_COMPLETION_HANDLER_CHECK( \
+ handler_type, handler) \
+ \
+ BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
+ sizeof(boost::asio::detail::zero_arg_handler_test( \
+ static_cast<handler_type*>(0))) == 1, \
+ "CompletionHandler type requirements not met") \
+ \
+ typedef boost::asio::detail::handler_type_requirements< \
+ sizeof( \
+ handler_type( \
+ static_cast<const handler_type&>(handler))) + \
+ sizeof( \
+ handler(), \
+ char(0))>
+
+#define BOOST_ASIO_READ_HANDLER_CHECK( \
+ handler_type, handler) \
+ \
+ BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
+ sizeof(boost::asio::detail::two_arg_handler_test( \
+ static_cast<handler_type*>(0), \
+ static_cast<const boost::system::error_code*>(0), \
+ static_cast<const std::size_t*>(0))) == 1, \
+ "ReadHandler type requirements not met") \
+ \
+ typedef boost::asio::detail::handler_type_requirements< \
+ sizeof( \
+ handler_type( \
+ static_cast<const handler_type&>(handler))) + \
+ sizeof( \
+ handler( \
+ boost::asio::detail::lvref<const boost::system::error_code>(), \
+ boost::asio::detail::lvref<const std::size_t>()), \
+ char(0))>
+
+#define BOOST_ASIO_WRITE_HANDLER_CHECK( \
+ handler_type, handler) \
+ \
+ BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
+ sizeof(boost::asio::detail::two_arg_handler_test( \
+ static_cast<handler_type*>(0), \
+ static_cast<const boost::system::error_code*>(0), \
+ static_cast<const std::size_t*>(0))) == 1, \
+ "WriteHandler type requirements not met") \
+ \
+ typedef boost::asio::detail::handler_type_requirements< \
+ sizeof( \
+ handler_type( \
+ static_cast<const handler_type&>(handler))) + \
+ sizeof( \
+ handler( \
+ boost::asio::detail::lvref<const boost::system::error_code>(), \
+ boost::asio::detail::lvref<const std::size_t>()), \
+ char(0))>
+
+#define BOOST_ASIO_ACCEPT_HANDLER_CHECK( \
+ handler_type, handler) \
+ \
+ BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
+ sizeof(boost::asio::detail::one_arg_handler_test( \
+ static_cast<handler_type*>(0), \
+ static_cast<const boost::system::error_code*>(0))) == 1, \
+ "AcceptHandler type requirements not met") \
+ \
+ typedef boost::asio::detail::handler_type_requirements< \
+ sizeof( \
+ handler_type( \
+ static_cast<const handler_type&>(handler))) + \
+ sizeof( \
+ handler( \
+ boost::asio::detail::lvref<const boost::system::error_code>()), \
+ char(0))>
+
+#define BOOST_ASIO_CONNECT_HANDLER_CHECK( \
+ handler_type, handler) \
+ \
+ BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
+ sizeof(boost::asio::detail::one_arg_handler_test( \
+ static_cast<handler_type*>(0), \
+ static_cast<const boost::system::error_code*>(0))) == 1, \
+ "ConnectHandler type requirements not met") \
+ \
+ typedef boost::asio::detail::handler_type_requirements< \
+ sizeof( \
+ handler_type( \
+ static_cast<const handler_type&>(handler))) + \
+ sizeof( \
+ handler( \
+ boost::asio::detail::lvref<const boost::system::error_code>()), \
+ char(0))>
+
+#define BOOST_ASIO_COMPOSED_CONNECT_HANDLER_CHECK( \
+ handler_type, handler, iter_type) \
+ \
+ BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
+ sizeof(boost::asio::detail::two_arg_handler_test( \
+ static_cast<handler_type*>(0), \
+ static_cast<const boost::system::error_code*>(0), \
+ static_cast<const iter_type*>(0))) == 1, \
+ "ComposedConnectHandler type requirements not met") \
+ \
+ typedef boost::asio::detail::handler_type_requirements< \
+ sizeof( \
+ handler_type( \
+ static_cast<const handler_type&>(handler))) + \
+ sizeof( \
+ handler( \
+ boost::asio::detail::lvref<const boost::system::error_code>(), \
+ boost::asio::detail::lvref<const iter_type>()), \
+ char(0))>
+
+#define BOOST_ASIO_RESOLVE_HANDLER_CHECK( \
+ handler_type, handler, iter_type) \
+ \
+ BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
+ sizeof(boost::asio::detail::two_arg_handler_test( \
+ static_cast<handler_type*>(0), \
+ static_cast<const boost::system::error_code*>(0), \
+ static_cast<const iter_type*>(0))) == 1, \
+ "ResolveHandler type requirements not met") \
+ \
+ typedef boost::asio::detail::handler_type_requirements< \
+ sizeof( \
+ handler_type( \
+ static_cast<const handler_type&>(handler))) + \
+ sizeof( \
+ handler( \
+ boost::asio::detail::lvref<const boost::system::error_code>(), \
+ boost::asio::detail::lvref<const iter_type>()), \
+ char(0))>
+
+#define BOOST_ASIO_WAIT_HANDLER_CHECK( \
+ handler_type, handler) \
+ \
+ BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
+ sizeof(boost::asio::detail::one_arg_handler_test( \
+ static_cast<handler_type*>(0), \
+ static_cast<const boost::system::error_code*>(0))) == 1, \
+ "WaitHandler type requirements not met") \
+ \
+ typedef boost::asio::detail::handler_type_requirements< \
+ sizeof( \
+ handler_type( \
+ static_cast<const handler_type&>(handler))) + \
+ sizeof( \
+ handler( \
+ boost::asio::detail::lvref<const boost::system::error_code>()), \
+ char(0))>
+
+#else // !defined(BOOST_ASIO_ENABLE_HANDLER_TYPE_REQUIREMENTS)
+
+#define BOOST_ASIO_COMPLETION_HANDLER_CHECK( \
+ handler_type, handler) \
+ typedef int
+
+#define BOOST_ASIO_READ_HANDLER_CHECK( \
+ handler_type, handler) \
+ typedef int
+
+#define BOOST_ASIO_WRITE_HANDLER_CHECK( \
+ handler_type, handler) \
+ typedef int
+
+#define BOOST_ASIO_ACCEPT_HANDLER_CHECK( \
+ handler_type, handler) \
+ typedef int
+
+#define BOOST_ASIO_CONNECT_HANDLER_CHECK( \
+ handler_type, handler) \
+ typedef int
+
+#define BOOST_ASIO_COMPOSED_CONNECT_HANDLER_CHECK( \
+ handler_type, handler, iter_type) \
+ typedef int
+
+#define BOOST_ASIO_RESOLVE_HANDLER_CHECK( \
+ handler_type, handler, iter_type) \
+ typedef int
+
+#define BOOST_ASIO_WAIT_HANDLER_CHECK( \
+ handler_type, handler) \
+ typedef int
+
+#endif // !defined(BOOST_ASIO_ENABLE_HANDLER_TYPE_REQUIREMENTS)
+
+} // namespace detail
+} // namespace asio
+} // namespace boost
+
+#endif // BOOST_ASIO_DETAIL_HANDLER_TYPE_REQUIREMENTS_HPP

Modified: trunk/boost/asio/detail/hash_map.hpp
==============================================================================
--- trunk/boost/asio/detail/hash_map.hpp (original)
+++ trunk/boost/asio/detail/hash_map.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -16,7 +16,7 @@
 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
 
 #include <boost/asio/detail/config.hpp>
-#include <cassert>
+#include <boost/assert.hpp>
 #include <list>
 #include <utility>
 #include <boost/asio/detail/noncopyable.hpp>
@@ -117,9 +117,9 @@
       iterator it = buckets_[bucket].first;
       if (it == values_.end())
         return values_.end();
- iterator end = buckets_[bucket].last;
- ++end;
- while (it != end)
+ iterator end_it = buckets_[bucket].last;
+ ++end_it;
+ while (it != end_it)
       {
         if (it->first == k)
           return it;
@@ -138,9 +138,9 @@
       const_iterator it = buckets_[bucket].first;
       if (it == values_.end())
         return it;
- const_iterator end = buckets_[bucket].last;
- ++end;
- while (it != end)
+ const_iterator end_it = buckets_[bucket].last;
+ ++end_it;
+ while (it != end_it)
       {
         if (it->first == k)
           return it;
@@ -164,15 +164,15 @@
       ++size_;
       return std::pair<iterator, bool>(buckets_[bucket].last, true);
     }
- iterator end = buckets_[bucket].last;
- ++end;
- while (it != end)
+ iterator end_it = buckets_[bucket].last;
+ ++end_it;
+ while (it != end_it)
     {
       if (it->first == v.first)
         return std::pair<iterator, bool>(it, false);
       ++it;
     }
- buckets_[bucket].last = values_insert(end, v);
+ buckets_[bucket].last = values_insert(end_it, v);
     ++size_;
     return std::pair<iterator, bool>(buckets_[bucket].last, true);
   }
@@ -180,7 +180,7 @@
   // Erase an entry from the map.
   void erase(iterator it)
   {
- assert(it != values_.end());
+ BOOST_ASSERT(it != values_.end());
 
     size_t bucket = calculate_hash_value(it->first) % num_buckets_;
     bool is_first = (it == buckets_[bucket].first);
@@ -212,9 +212,9 @@
     size_ = 0;
 
     // Initialise all buckets to empty.
- iterator end = values_.end();
+ iterator end_it = values_.end();
     for (size_t i = 0; i < num_buckets_; ++i)
- buckets_[i].first = buckets_[i].last = end;
+ buckets_[i].first = buckets_[i].last = end_it;
   }
 
 private:
@@ -245,21 +245,21 @@
       return;
     num_buckets_ = num_buckets;
 
- iterator end = values_.end();
+ iterator end_iter = values_.end();
 
     // Update number of buckets and initialise all buckets to empty.
     bucket_type* tmp = new bucket_type[num_buckets_];
     delete[] buckets_;
     buckets_ = tmp;
     for (std::size_t i = 0; i < num_buckets_; ++i)
- buckets_[i].first = buckets_[i].last = end;
+ buckets_[i].first = buckets_[i].last = end_iter;
 
     // Put all values back into the hash.
     iterator iter = values_.begin();
- while (iter != end)
+ while (iter != end_iter)
     {
       std::size_t bucket = calculate_hash_value(iter->first) % num_buckets_;
- if (buckets_[bucket].last == end)
+ if (buckets_[bucket].last == end_iter)
       {
         buckets_[bucket].first = buckets_[bucket].last = iter++;
       }

Modified: trunk/boost/asio/detail/impl/descriptor_ops.ipp
==============================================================================
--- trunk/boost/asio/detail/impl/descriptor_ops.ipp (original)
+++ trunk/boost/asio/detail/impl/descriptor_ops.ipp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -65,8 +65,8 @@
   return result;
 }
 
-bool set_internal_non_blocking(int d,
- state_type& state, boost::system::error_code& ec)
+bool set_user_non_blocking(int d, state_type& state,
+ bool value, boost::system::error_code& ec)
 {
   if (d == -1)
   {
@@ -80,17 +80,71 @@
   if (result >= 0)
   {
     errno = 0;
- result = error_wrapper(::fcntl(d, F_SETFL, result | O_NONBLOCK), ec);
+ int flag = (value ? (result | O_NONBLOCK) : (result & ~O_NONBLOCK));
+ result = error_wrapper(::fcntl(d, F_SETFL, flag), ec);
   }
 #else // defined(__SYMBIAN32__)
- ioctl_arg_type arg = 1;
+ ioctl_arg_type arg = (value ? 1 : 0);
   int result = error_wrapper(::ioctl(d, FIONBIO, &arg), ec);
 #endif // defined(__SYMBIAN32__)
 
   if (result >= 0)
   {
     ec = boost::system::error_code();
- state |= internal_non_blocking;
+ if (value)
+ state |= user_set_non_blocking;
+ else
+ {
+ // Clearing the user-set non-blocking mode always overrides any
+ // internally-set non-blocking flag. Any subsequent asynchronous
+ // operations will need to re-enable non-blocking I/O.
+ state &= ~(user_set_non_blocking | internal_non_blocking);
+ }
+ return true;
+ }
+
+ return false;
+}
+
+bool set_internal_non_blocking(int d, state_type& state,
+ bool value, boost::system::error_code& ec)
+{
+ if (d == -1)
+ {
+ ec = boost::asio::error::bad_descriptor;
+ return false;
+ }
+
+ if (!value && (state & user_set_non_blocking))
+ {
+ // It does not make sense to clear the internal non-blocking flag if the
+ // user still wants non-blocking behaviour. Return an error and let the
+ // caller figure out whether to update the user-set non-blocking flag.
+ ec = boost::asio::error::invalid_argument;
+ return false;
+ }
+
+ errno = 0;
+#if defined(__SYMBIAN32__)
+ int result = error_wrapper(::fcntl(d, F_GETFL, 0), ec);
+ if (result >= 0)
+ {
+ errno = 0;
+ int flag = (value ? (result | O_NONBLOCK) : (result & ~O_NONBLOCK));
+ result = error_wrapper(::fcntl(d, F_SETFL, flag), ec);
+ }
+#else // defined(__SYMBIAN32__)
+ ioctl_arg_type arg = (value ? 1 : 0);
+ int result = error_wrapper(::ioctl(d, FIONBIO, &arg), ec);
+#endif // defined(__SYMBIAN32__)
+
+ if (result >= 0)
+ {
+ ec = boost::system::error_code();
+ if (value)
+ state |= internal_non_blocking;
+ else
+ state &= ~internal_non_blocking;
     return true;
   }
 

Modified: trunk/boost/asio/detail/impl/dev_poll_reactor.hpp
==============================================================================
--- trunk/boost/asio/detail/impl/dev_poll_reactor.hpp (original)
+++ trunk/boost/asio/detail/impl/dev_poll_reactor.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -58,11 +58,12 @@
 
 template <typename Time_Traits>
 std::size_t dev_poll_reactor::cancel_timer(timer_queue<Time_Traits>& queue,
- typename timer_queue<Time_Traits>::per_timer_data& timer)
+ typename timer_queue<Time_Traits>::per_timer_data& timer,
+ std::size_t max_cancelled)
 {
   boost::asio::detail::mutex::scoped_lock lock(mutex_);
   op_queue<operation> ops;
- std::size_t n = queue.cancel_timer(timer, ops);
+ std::size_t n = queue.cancel_timer(timer, ops, max_cancelled);
   lock.unlock();
   io_service_.post_deferred_completions(ops);
   return n;

Modified: trunk/boost/asio/detail/impl/dev_poll_reactor.ipp
==============================================================================
--- trunk/boost/asio/detail/impl/dev_poll_reactor.ipp (original)
+++ trunk/boost/asio/detail/impl/dev_poll_reactor.ipp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -129,8 +129,8 @@
   cancel_ops_unlocked(descriptor, boost::asio::error::operation_aborted);
 }
 
-void dev_poll_reactor::close_descriptor(socket_type descriptor,
- dev_poll_reactor::per_descriptor_data&)
+void dev_poll_reactor::deregister_descriptor(socket_type descriptor,
+ dev_poll_reactor::per_descriptor_data&, bool)
 {
   boost::asio::detail::mutex::scoped_lock lock(mutex_);
 

Modified: trunk/boost/asio/detail/impl/epoll_reactor.hpp
==============================================================================
--- trunk/boost/asio/detail/impl/epoll_reactor.hpp (original)
+++ trunk/boost/asio/detail/impl/epoll_reactor.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -56,11 +56,12 @@
 
 template <typename Time_Traits>
 std::size_t epoll_reactor::cancel_timer(timer_queue<Time_Traits>& queue,
- typename timer_queue<Time_Traits>::per_timer_data& timer)
+ typename timer_queue<Time_Traits>::per_timer_data& timer,
+ std::size_t max_cancelled)
 {
   mutex::scoped_lock lock(mutex_);
   op_queue<operation> ops;
- std::size_t n = queue.cancel_timer(timer, ops);
+ std::size_t n = queue.cancel_timer(timer, ops, max_cancelled);
   lock.unlock();
   io_service_.post_deferred_completions(ops);
   return n;

Modified: trunk/boost/asio/detail/impl/epoll_reactor.ipp
==============================================================================
--- trunk/boost/asio/detail/impl/epoll_reactor.ipp (original)
+++ trunk/boost/asio/detail/impl/epoll_reactor.ipp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -185,8 +185,8 @@
   io_service_.post_deferred_completions(ops);
 }
 
-void epoll_reactor::close_descriptor(socket_type,
- epoll_reactor::per_descriptor_data& descriptor_data)
+void epoll_reactor::deregister_descriptor(socket_type descriptor,
+ epoll_reactor::per_descriptor_data& descriptor_data, bool closing)
 {
   if (!descriptor_data)
     return;
@@ -196,8 +196,16 @@
 
   if (!descriptor_data->shutdown_)
   {
- // Remove the descriptor from the set of known descriptors. The descriptor
- // will be automatically removed from the epoll set when it is closed.
+ if (closing)
+ {
+ // The descriptor will be automatically removed from the epoll set when
+ // it is closed.
+ }
+ else
+ {
+ epoll_event ev = { 0, { 0 } };
+ epoll_ctl(epoll_fd_, EPOLL_CTL_DEL, descriptor, &ev);
+ }
 
     op_queue<operation> ops;
     for (int i = 0; i < max_ops; ++i)

Modified: trunk/boost/asio/detail/impl/kqueue_reactor.hpp
==============================================================================
--- trunk/boost/asio/detail/impl/kqueue_reactor.hpp (original)
+++ trunk/boost/asio/detail/impl/kqueue_reactor.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -60,11 +60,12 @@
 
 template <typename Time_Traits>
 std::size_t kqueue_reactor::cancel_timer(timer_queue<Time_Traits>& queue,
- typename timer_queue<Time_Traits>::per_timer_data& timer)
+ typename timer_queue<Time_Traits>::per_timer_data& timer,
+ std::size_t max_cancelled)
 {
   boost::asio::detail::mutex::scoped_lock lock(mutex_);
   op_queue<operation> ops;
- std::size_t n = queue.cancel_timer(timer, ops);
+ std::size_t n = queue.cancel_timer(timer, ops, max_cancelled);
   lock.unlock();
   io_service_.post_deferred_completions(ops);
   return n;

Modified: trunk/boost/asio/detail/impl/kqueue_reactor.ipp
==============================================================================
--- trunk/boost/asio/detail/impl/kqueue_reactor.ipp (original)
+++ trunk/boost/asio/detail/impl/kqueue_reactor.ipp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -187,8 +187,8 @@
   io_service_.post_deferred_completions(ops);
 }
 
-void kqueue_reactor::close_descriptor(socket_type,
- kqueue_reactor::per_descriptor_data& descriptor_data)
+void kqueue_reactor::deregister_descriptor(socket_type descriptor,
+ kqueue_reactor::per_descriptor_data& descriptor_data, bool closing)
 {
   if (!descriptor_data)
     return;
@@ -198,8 +198,20 @@
 
   if (!descriptor_data->shutdown_)
   {
- // Remove the descriptor from the set of known descriptors. The descriptor
- // will be automatically removed from the kqueue set when it is closed.
+ if (closing)
+ {
+ // The descriptor will be automatically removed from the kqueue when it
+ // is closed.
+ }
+ else
+ {
+ struct kevent events[2];
+ BOOST_ASIO_KQUEUE_EV_SET(&events[0], descriptor,
+ EVFILT_READ, EV_DELETE, 0, 0, 0);
+ BOOST_ASIO_KQUEUE_EV_SET(&events[1], descriptor,
+ EVFILT_WRITE, EV_DELETE, 0, 0, 0);
+ ::kevent(kqueue_fd_, events, 2, 0, 0, 0);
+ }
 
     op_queue<operation> ops;
     for (int i = 0; i < max_ops; ++i)

Modified: trunk/boost/asio/detail/impl/reactive_descriptor_service.ipp
==============================================================================
--- trunk/boost/asio/detail/impl/reactive_descriptor_service.ipp (original)
+++ trunk/boost/asio/detail/impl/reactive_descriptor_service.ipp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -50,7 +50,10 @@
     reactive_descriptor_service::implementation_type& impl)
 {
   if (is_open(impl))
- reactor_.close_descriptor(impl.descriptor_, impl.reactor_data_);
+ {
+ reactor_.deregister_descriptor(impl.descriptor_, impl.reactor_data_,
+ (impl.state_ & descriptor_ops::possible_dup) == 0);
+ }
 
   boost::system::error_code ignored_ec;
   descriptor_ops::close(impl.descriptor_, impl.state_, ignored_ec);
@@ -58,7 +61,7 @@
 
 boost::system::error_code reactive_descriptor_service::assign(
     reactive_descriptor_service::implementation_type& impl,
- const native_type& native_descriptor, boost::system::error_code& ec)
+ const native_handle_type& native_descriptor, boost::system::error_code& ec)
 {
   if (is_open(impl))
   {
@@ -75,7 +78,7 @@
   }
 
   impl.descriptor_ = native_descriptor;
- impl.state_ = 0;
+ impl.state_ = descriptor_ops::possible_dup;
   ec = boost::system::error_code();
   return ec;
 }
@@ -85,7 +88,10 @@
     boost::system::error_code& ec)
 {
   if (is_open(impl))
- reactor_.close_descriptor(impl.descriptor_, impl.reactor_data_);
+ {
+ reactor_.deregister_descriptor(impl.descriptor_, impl.reactor_data_,
+ (impl.state_ & descriptor_ops::possible_dup) == 0);
+ }
 
   if (descriptor_ops::close(impl.descriptor_, impl.state_, ec) == 0)
     construct(impl);
@@ -93,6 +99,21 @@
   return ec;
 }
 
+reactive_descriptor_service::native_handle_type
+reactive_descriptor_service::release(
+ reactive_descriptor_service::implementation_type& impl)
+{
+ native_handle_type descriptor = impl.descriptor_;
+
+ if (is_open(impl))
+ {
+ reactor_.deregister_descriptor(impl.descriptor_, impl.reactor_data_, false);
+ construct(impl);
+ }
+
+ return descriptor;
+}
+
 boost::system::error_code reactive_descriptor_service::cancel(
     reactive_descriptor_service::implementation_type& impl,
     boost::system::error_code& ec)
@@ -110,16 +131,16 @@
 
 void reactive_descriptor_service::start_op(
     reactive_descriptor_service::implementation_type& impl,
- int op_type, reactor_op* op, bool non_blocking, bool noop)
+ int op_type, reactor_op* op, bool is_non_blocking, bool noop)
 {
   if (!noop)
   {
     if ((impl.state_ & descriptor_ops::non_blocking) ||
         descriptor_ops::set_internal_non_blocking(
- impl.descriptor_, impl.state_, op->ec_))
+ impl.descriptor_, impl.state_, true, op->ec_))
     {
       reactor_.start_op(op_type, impl.descriptor_,
- impl.reactor_data_, op, non_blocking);
+ impl.reactor_data_, op, is_non_blocking);
       return;
     }
   }

Modified: trunk/boost/asio/detail/impl/reactive_serial_port_service.ipp
==============================================================================
--- trunk/boost/asio/detail/impl/reactive_serial_port_service.ipp (original)
+++ trunk/boost/asio/detail/impl/reactive_serial_port_service.ipp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -113,7 +113,7 @@
   termios ios;
   errno = 0;
   descriptor_ops::error_wrapper(::tcgetattr(
- descriptor_service_.native(impl), &ios), ec);
+ descriptor_service_.native_handle(impl), &ios), ec);
   if (ec)
     return ec;
 
@@ -122,7 +122,7 @@
 
   errno = 0;
   descriptor_ops::error_wrapper(::tcsetattr(
- descriptor_service_.native(impl), TCSANOW, &ios), ec);
+ descriptor_service_.native_handle(impl), TCSANOW, &ios), ec);
   return ec;
 }
 
@@ -134,7 +134,7 @@
   termios ios;
   errno = 0;
   descriptor_ops::error_wrapper(::tcgetattr(
- descriptor_service_.native(impl), &ios), ec);
+ descriptor_service_.native_handle(impl), &ios), ec);
   if (ec)
     return ec;
 

Modified: trunk/boost/asio/detail/impl/reactive_socket_service_base.ipp
==============================================================================
--- trunk/boost/asio/detail/impl/reactive_socket_service_base.ipp (original)
+++ trunk/boost/asio/detail/impl/reactive_socket_service_base.ipp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -50,7 +50,8 @@
 {
   if (impl.socket_ != invalid_socket)
   {
- reactor_.close_descriptor(impl.socket_, impl.reactor_data_);
+ reactor_.deregister_descriptor(impl.socket_, impl.reactor_data_,
+ (impl.state_ & socket_ops::possible_dup) == 0);
 
     boost::system::error_code ignored_ec;
     socket_ops::close(impl.socket_, impl.state_, true, ignored_ec);
@@ -62,7 +63,10 @@
     boost::system::error_code& ec)
 {
   if (is_open(impl))
- reactor_.close_descriptor(impl.socket_, impl.reactor_data_);
+ {
+ reactor_.deregister_descriptor(impl.socket_, impl.reactor_data_,
+ (impl.state_ & socket_ops::possible_dup) == 0);
+ }
 
   if (socket_ops::close(impl.socket_, impl.state_, true, ec) == 0)
     construct(impl);
@@ -119,7 +123,7 @@
 
 boost::system::error_code reactive_socket_service_base::do_assign(
     reactive_socket_service_base::base_implementation_type& impl, int type,
- const reactive_socket_service_base::native_type& native_socket,
+ const reactive_socket_service_base::native_handle_type& native_socket,
     boost::system::error_code& ec)
 {
   if (is_open(impl))
@@ -143,22 +147,23 @@
   case SOCK_DGRAM: impl.state_ = socket_ops::datagram_oriented; break;
   default: impl.state_ = 0; break;
   }
+ impl.state_ |= socket_ops::possible_dup;
   ec = boost::system::error_code();
   return ec;
 }
 
 void reactive_socket_service_base::start_op(
     reactive_socket_service_base::base_implementation_type& impl,
- int op_type, reactor_op* op, bool non_blocking, bool noop)
+ int op_type, reactor_op* op, bool is_non_blocking, bool noop)
 {
   if (!noop)
   {
     if ((impl.state_ & socket_ops::non_blocking)
         || socket_ops::set_internal_non_blocking(
- impl.socket_, impl.state_, op->ec_))
+ impl.socket_, impl.state_, true, op->ec_))
     {
       reactor_.start_op(op_type, impl.socket_,
- impl.reactor_data_, op, non_blocking);
+ impl.reactor_data_, op, is_non_blocking);
       return;
     }
   }
@@ -185,7 +190,7 @@
 {
   if ((impl.state_ & socket_ops::non_blocking)
       || socket_ops::set_internal_non_blocking(
- impl.socket_, impl.state_, op->ec_))
+ impl.socket_, impl.state_, true, op->ec_))
   {
     if (socket_ops::connect(impl.socket_, addr, addrlen, op->ec_) != 0)
     {

Modified: trunk/boost/asio/detail/impl/select_reactor.hpp
==============================================================================
--- trunk/boost/asio/detail/impl/select_reactor.hpp (original)
+++ trunk/boost/asio/detail/impl/select_reactor.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -62,11 +62,12 @@
 
 template <typename Time_Traits>
 std::size_t select_reactor::cancel_timer(timer_queue<Time_Traits>& queue,
- typename timer_queue<Time_Traits>::per_timer_data& timer)
+ typename timer_queue<Time_Traits>::per_timer_data& timer,
+ std::size_t max_cancelled)
 {
   boost::asio::detail::mutex::scoped_lock lock(mutex_);
   op_queue<operation> ops;
- std::size_t n = queue.cancel_timer(timer, ops);
+ std::size_t n = queue.cancel_timer(timer, ops, max_cancelled);
   lock.unlock();
   io_service_.post_deferred_completions(ops);
   return n;

Modified: trunk/boost/asio/detail/impl/select_reactor.ipp
==============================================================================
--- trunk/boost/asio/detail/impl/select_reactor.ipp (original)
+++ trunk/boost/asio/detail/impl/select_reactor.ipp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -119,8 +119,8 @@
   cancel_ops_unlocked(descriptor, boost::asio::error::operation_aborted);
 }
 
-void select_reactor::close_descriptor(socket_type descriptor,
- select_reactor::per_descriptor_data&)
+void select_reactor::deregister_descriptor(socket_type descriptor,
+ select_reactor::per_descriptor_data&, bool)
 {
   boost::asio::detail::mutex::scoped_lock lock(mutex_);
   cancel_ops_unlocked(descriptor, boost::asio::error::operation_aborted);

Modified: trunk/boost/asio/detail/impl/service_registry.ipp
==============================================================================
--- trunk/boost/asio/detail/impl/service_registry.ipp (original)
+++ trunk/boost/asio/detail/impl/service_registry.ipp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -121,7 +121,7 @@
     const boost::asio::io_service::service::key& key,
     boost::asio::io_service::service* new_service)
 {
- if (&owner_ != &new_service->io_service())
+ if (&owner_ != &new_service->get_io_service())
     boost::throw_exception(invalid_service_owner());
 
   boost::asio::detail::mutex::scoped_lock lock(mutex_);

Modified: trunk/boost/asio/detail/impl/socket_ops.ipp
==============================================================================
--- trunk/boost/asio/detail/impl/socket_ops.ipp (original)
+++ trunk/boost/asio/detail/impl/socket_ops.ipp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -323,8 +323,52 @@
   return result;
 }
 
+bool set_user_non_blocking(socket_type s,
+ state_type& state, bool value, boost::system::error_code& ec)
+{
+ if (s == invalid_socket)
+ {
+ ec = boost::asio::error::bad_descriptor;
+ return false;
+ }
+
+ clear_last_error();
+#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
+ ioctl_arg_type arg = (value ? 1 : 0);
+ int result = error_wrapper(::ioctlsocket(s, FIONBIO, &arg), ec);
+#elif defined(__SYMBIAN32__)
+ int result = error_wrapper(::fcntl(s, F_GETFL, 0), ec);
+ if (result >= 0)
+ {
+ clear_last_error();
+ int flag = (value ? (result | O_NONBLOCK) : (result & ~O_NONBLOCK));
+ result = error_wrapper(::fcntl(s, F_SETFL, flag), ec);
+ }
+#else
+ ioctl_arg_type arg = (value ? 1 : 0);
+ int result = error_wrapper(::ioctl(s, FIONBIO, &arg), ec);
+#endif
+
+ if (result >= 0)
+ {
+ ec = boost::system::error_code();
+ if (value)
+ state |= user_set_non_blocking;
+ else
+ {
+ // Clearing the user-set non-blocking mode always overrides any
+ // internally-set non-blocking flag. Any subsequent asynchronous
+ // operations will need to re-enable non-blocking I/O.
+ state &= ~(user_set_non_blocking | internal_non_blocking);
+ }
+ return true;
+ }
+
+ return false;
+}
+
 bool set_internal_non_blocking(socket_type s,
- state_type& state, boost::system::error_code& ec)
+ state_type& state, bool value, boost::system::error_code& ec)
 {
   if (s == invalid_socket)
   {
@@ -332,26 +376,39 @@
     return false;
   }
 
+ if (!value && (state & user_set_non_blocking))
+ {
+ // It does not make sense to clear the internal non-blocking flag if the
+ // user still wants non-blocking behaviour. Return an error and let the
+ // caller figure out whether to update the user-set non-blocking flag.
+ ec = boost::asio::error::invalid_argument;
+ return false;
+ }
+
   clear_last_error();
 #if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
- ioctl_arg_type arg = 1;
+ ioctl_arg_type arg = (value ? 1 : 0);
   int result = error_wrapper(::ioctlsocket(s, FIONBIO, &arg), ec);
 #elif defined(__SYMBIAN32__)
   int result = error_wrapper(::fcntl(s, F_GETFL, 0), ec);
   if (result >= 0)
   {
     clear_last_error();
- result = error_wrapper(::fcntl(s, F_SETFL, result | O_NONBLOCK), ec);
+ int flag = (value ? (result | O_NONBLOCK) : (result & ~O_NONBLOCK));
+ result = error_wrapper(::fcntl(s, F_SETFL, flag), ec);
   }
 #else
- ioctl_arg_type arg = 1;
+ ioctl_arg_type arg = (value ? 1 : 0);
   int result = error_wrapper(::ioctl(s, FIONBIO, &arg), ec);
 #endif
 
   if (result >= 0)
   {
     ec = boost::system::error_code();
- state |= internal_non_blocking;
+ if (value)
+ state |= internal_non_blocking;
+ else
+ state &= ~internal_non_blocking;
     return true;
   }
 
@@ -863,6 +920,116 @@
 
 #endif // defined(BOOST_ASIO_HAS_IOCP)
 
+int recvmsg(socket_type s, buf* bufs, size_t count,
+ int in_flags, int& out_flags, boost::system::error_code& ec)
+{
+ clear_last_error();
+#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
+ out_flags = 0;
+ return socket_ops::recv(s, bufs, count, in_flags, ec);
+#else // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
+ msghdr msg = msghdr();
+ msg.msg_iov = bufs;
+ msg.msg_iovlen = count;
+ int result = error_wrapper(::recvmsg(s, &msg, in_flags), ec);
+ if (result >= 0)
+ {
+ ec = boost::system::error_code();
+ out_flags = msg.msg_flags;
+ }
+ else
+ out_flags = 0;
+ return result;
+#endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
+}
+
+size_t sync_recvmsg(socket_type s, state_type state,
+ buf* bufs, size_t count, int in_flags, int& out_flags,
+ boost::system::error_code& ec)
+{
+ if (s == invalid_socket)
+ {
+ ec = boost::asio::error::bad_descriptor;
+ return 0;
+ }
+
+ // Read some data.
+ for (;;)
+ {
+ // Try to complete the operation without blocking.
+ int bytes = socket_ops::recvmsg(s, bufs, count, in_flags, out_flags, ec);
+
+ // Check if operation succeeded.
+ if (bytes >= 0)
+ return bytes;
+
+ // Operation failed.
+ if ((state & user_set_non_blocking)
+ || (ec != boost::asio::error::would_block
+ && ec != boost::asio::error::try_again))
+ return 0;
+
+ // Wait for socket to become ready.
+ if (socket_ops::poll_read(s, ec) < 0)
+ return 0;
+ }
+}
+
+#if defined(BOOST_ASIO_HAS_IOCP)
+
+void complete_iocp_recvmsg(
+ const weak_cancel_token_type& cancel_token,
+ boost::system::error_code& ec)
+{
+ // Map non-portable errors to their portable counterparts.
+ if (ec.value() == ERROR_NETNAME_DELETED)
+ {
+ if (cancel_token.expired())
+ ec = boost::asio::error::operation_aborted;
+ else
+ ec = boost::asio::error::connection_reset;
+ }
+ else if (ec.value() == ERROR_PORT_UNREACHABLE)
+ {
+ ec = boost::asio::error::connection_refused;
+ }
+}
+
+#else // defined(BOOST_ASIO_HAS_IOCP)
+
+bool non_blocking_recvmsg(socket_type s,
+ buf* bufs, size_t count, int in_flags, int& out_flags,
+ boost::system::error_code& ec, size_t& bytes_transferred)
+{
+ for (;;)
+ {
+ // Read some data.
+ int bytes = socket_ops::recvmsg(s, bufs, count, in_flags, out_flags, ec);
+
+ // Retry operation if interrupted by signal.
+ if (ec == boost::asio::error::interrupted)
+ continue;
+
+ // Check if we need to run the operation again.
+ if (ec == boost::asio::error::would_block
+ || ec == boost::asio::error::try_again)
+ return false;
+
+ // Operation is complete.
+ if (bytes >= 0)
+ {
+ ec = boost::system::error_code();
+ bytes_transferred = bytes;
+ }
+ else
+ bytes_transferred = 0;
+
+ return true;
+ }
+}
+
+#endif // defined(BOOST_ASIO_HAS_IOCP)
+
 int send(socket_type s, const buf* bufs, size_t count, int flags,
     boost::system::error_code& ec)
 {
@@ -1680,7 +1847,8 @@
     using namespace std; // For strcat and sprintf.
     char if_name[IF_NAMESIZE + 1] = "%";
     const in6_addr_type* ipv6_address = static_cast<const in6_addr_type*>(src);
- bool is_link_local = IN6_IS_ADDR_LINKLOCAL(ipv6_address);
+ bool is_link_local = ((ipv6_address->s6_addr[0] == 0xfe)
+ && ((ipv6_address->s6_addr[1] & 0xc0) == 0x80));
     if (!is_link_local || if_indextoname(scope_id, if_name + 1) == 0)
       sprintf(if_name + 1, "%lu", scope_id);
     strcat(dest, if_name);
@@ -1764,7 +1932,8 @@
     if (const char* if_name = strchr(src, '%'))
     {
       in6_addr_type* ipv6_address = static_cast<in6_addr_type*>(dest);
- bool is_link_local = IN6_IS_ADDR_LINKLOCAL(ipv6_address);
+ bool is_link_local = ((ipv6_address->s6_addr[0] == 0xfe)
+ && ((ipv6_address->s6_addr[1] & 0xc0) == 0x80));
       if (is_link_local)
         *scope_id = if_nametoindex(if_name + 1);
       if (*scope_id == 0)

Modified: trunk/boost/asio/detail/impl/strand_service.hpp
==============================================================================
--- trunk/boost/asio/detail/impl/strand_service.hpp (original)
+++ trunk/boost/asio/detail/impl/strand_service.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -56,7 +56,7 @@
 
 template <typename Handler>
 void strand_service::dispatch(strand_service::implementation_type& impl,
- Handler handler)
+ Handler& handler)
 {
   // If we are already in the strand then the handler can run immediately.
   if (call_stack<strand_impl>::contains(impl))
@@ -112,7 +112,7 @@
 // Request the io_service to invoke the given handler and return immediately.
 template <typename Handler>
 void strand_service::post(strand_service::implementation_type& impl,
- Handler handler)
+ Handler& handler)
 {
   // Allocate and construct an operation to wrap the handler.
   typedef completion_handler<Handler> op;

Modified: trunk/boost/asio/detail/impl/task_io_service.hpp
==============================================================================
--- trunk/boost/asio/detail/impl/task_io_service.hpp (original)
+++ trunk/boost/asio/detail/impl/task_io_service.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -28,7 +28,7 @@
 namespace detail {
 
 template <typename Handler>
-void task_io_service::dispatch(Handler handler)
+void task_io_service::dispatch(Handler& handler)
 {
   if (call_stack<task_io_service>::contains(this))
   {
@@ -40,7 +40,7 @@
 }
 
 template <typename Handler>
-void task_io_service::post(Handler handler)
+void task_io_service::post(Handler& handler)
 {
   // Allocate and construct an operation to wrap the handler.
   typedef completion_handler<Handler> op;

Modified: trunk/boost/asio/detail/impl/task_io_service.ipp
==============================================================================
--- trunk/boost/asio/detail/impl/task_io_service.ipp (original)
+++ trunk/boost/asio/detail/impl/task_io_service.ipp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -194,6 +194,12 @@
   stop_all_threads(lock);
 }
 
+bool task_io_service::stopped() const
+{
+ mutex::scoped_lock lock(mutex_);
+ return stopped_;
+}
+
 void task_io_service::reset()
 {
   mutex::scoped_lock lock(mutex_);

Modified: trunk/boost/asio/detail/impl/timer_queue.ipp
==============================================================================
--- trunk/boost/asio/detail/impl/timer_queue.ipp (original)
+++ trunk/boost/asio/detail/impl/timer_queue.ipp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -71,9 +71,9 @@
 }
 
 std::size_t timer_queue<time_traits<boost::posix_time::ptime> >::cancel_timer(
- per_timer_data& timer, op_queue<operation>& ops)
+ per_timer_data& timer, op_queue<operation>& ops, std::size_t max_cancelled)
 {
- return impl_.cancel_timer(timer, ops);
+ return impl_.cancel_timer(timer, ops, max_cancelled);
 }
 
 } // namespace detail

Modified: trunk/boost/asio/detail/impl/win_iocp_handle_service.ipp
==============================================================================
--- trunk/boost/asio/detail/impl/win_iocp_handle_service.ipp (original)
+++ trunk/boost/asio/detail/impl/win_iocp_handle_service.ipp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -119,7 +119,7 @@
 
 boost::system::error_code win_iocp_handle_service::assign(
     win_iocp_handle_service::implementation_type& impl,
- const native_type& native_handle, boost::system::error_code& ec)
+ const native_handle_type& handle, boost::system::error_code& ec)
 {
   if (is_open(impl))
   {
@@ -127,10 +127,10 @@
     return ec;
   }
 
- if (iocp_service_.register_handle(native_handle, ec))
+ if (iocp_service_.register_handle(handle, ec))
     return ec;
 
- impl.handle_ = native_handle;
+ impl.handle_ = handle;
   ec = boost::system::error_code();
   return ec;
 }

Modified: trunk/boost/asio/detail/impl/win_iocp_io_service.hpp
==============================================================================
--- trunk/boost/asio/detail/impl/win_iocp_io_service.hpp (original)
+++ trunk/boost/asio/detail/impl/win_iocp_io_service.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -32,7 +32,7 @@
 namespace detail {
 
 template <typename Handler>
-void win_iocp_io_service::dispatch(Handler handler)
+void win_iocp_io_service::dispatch(Handler& handler)
 {
   if (call_stack<win_iocp_io_service>::contains(this))
   {
@@ -44,7 +44,7 @@
 }
 
 template <typename Handler>
-void win_iocp_io_service::post(Handler handler)
+void win_iocp_io_service::post(Handler& handler)
 {
   // Allocate and construct an operation to wrap the handler.
   typedef completion_handler<Handler> op;
@@ -93,7 +93,8 @@
 
 template <typename Time_Traits>
 std::size_t win_iocp_io_service::cancel_timer(timer_queue<Time_Traits>& queue,
- typename timer_queue<Time_Traits>::per_timer_data& timer)
+ typename timer_queue<Time_Traits>::per_timer_data& timer,
+ std::size_t max_cancelled)
 {
   // If the service has been shut down we silently ignore the cancellation.
   if (::InterlockedExchangeAdd(&shutdown_, 0) != 0)
@@ -101,7 +102,7 @@
 
   mutex::scoped_lock lock(dispatch_mutex_);
   op_queue<win_iocp_operation> ops;
- std::size_t n = queue.cancel_timer(timer, ops);
+ std::size_t n = queue.cancel_timer(timer, ops, max_cancelled);
   post_deferred_completions(ops);
   return n;
 }

Modified: trunk/boost/asio/detail/impl/win_iocp_serial_port_service.ipp
==============================================================================
--- trunk/boost/asio/detail/impl/win_iocp_serial_port_service.ipp (original)
+++ trunk/boost/asio/detail/impl/win_iocp_serial_port_service.ipp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -127,7 +127,7 @@
   ::DCB dcb;
   memset(&dcb, 0, sizeof(DCB));
   dcb.DCBlength = sizeof(DCB);
- if (!::GetCommState(handle_service_.native(impl), &dcb))
+ if (!::GetCommState(handle_service_.native_handle(impl), &dcb))
   {
     DWORD last_error = ::GetLastError();
     ec = boost::system::error_code(last_error,
@@ -138,7 +138,7 @@
   if (store(option, dcb, ec))
     return ec;
 
- if (!::SetCommState(handle_service_.native(impl), &dcb))
+ if (!::SetCommState(handle_service_.native_handle(impl), &dcb))
   {
     DWORD last_error = ::GetLastError();
     ec = boost::system::error_code(last_error,
@@ -160,7 +160,7 @@
   ::DCB dcb;
   memset(&dcb, 0, sizeof(DCB));
   dcb.DCBlength = sizeof(DCB);
- if (!::GetCommState(handle_service_.native(impl), &dcb))
+ if (!::GetCommState(handle_service_.native_handle(impl), &dcb))
   {
     DWORD last_error = ::GetLastError();
     ec = boost::system::error_code(last_error,

Modified: trunk/boost/asio/detail/impl/win_iocp_socket_service_base.ipp
==============================================================================
--- trunk/boost/asio/detail/impl/win_iocp_socket_service_base.ipp (original)
+++ trunk/boost/asio/detail/impl/win_iocp_socket_service_base.ipp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -99,7 +99,7 @@
           interlocked_compare_exchange_pointer(
             reinterpret_cast<void**>(&reactor_), 0, 0));
     if (r)
- r->close_descriptor(impl.socket_, impl.reactor_data_);
+ r->deregister_descriptor(impl.socket_, impl.reactor_data_, true);
   }
 
   if (socket_ops::close(impl.socket_, impl.state_, false, ec) == 0)
@@ -474,7 +474,7 @@
 
   if ((impl.state_ & socket_ops::non_blocking) != 0
       || socket_ops::set_internal_non_blocking(
- impl.socket_, impl.state_, op->ec_))
+ impl.socket_, impl.state_, true, op->ec_))
   {
     if (socket_ops::connect(impl.socket_, addr, addrlen, op->ec_) != 0)
     {
@@ -504,7 +504,7 @@
           interlocked_compare_exchange_pointer(
             reinterpret_cast<void**>(&reactor_), 0, 0));
     if (r)
- r->close_descriptor(impl.socket_, impl.reactor_data_);
+ r->deregister_descriptor(impl.socket_, impl.reactor_data_, true);
   }
 
   boost::system::error_code ignored_ec;

Modified: trunk/boost/asio/detail/impl/win_thread.ipp
==============================================================================
--- trunk/boost/asio/detail/impl/win_thread.ipp (original)
+++ trunk/boost/asio/detail/impl/win_thread.ipp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -102,12 +102,12 @@
 
 unsigned int __stdcall win_thread_function(void* arg)
 {
- std::auto_ptr<win_thread::func_base> func(
- static_cast<win_thread::func_base*>(arg));
+ win_thread::auto_func_base_ptr func = {
+ static_cast<win_thread::func_base*>(arg) };
 
- ::SetEvent(func->entry_event_);
+ ::SetEvent(func.ptr->entry_event_);
 
- func->run();
+ func.ptr->run();
 
   // Signal that the thread has finished its work, but rather than returning go
   // to sleep to put the thread into a well known state. If the thread is being
@@ -115,8 +115,9 @@
   // TerminateThread (to avoid a deadlock in DllMain). Otherwise, the SleepEx
   // call will be interrupted using QueueUserAPC and the thread will shut down
   // cleanly.
- HANDLE exit_event = func->exit_event_;
- func.reset();
+ HANDLE exit_event = func.ptr->exit_event_;
+ delete func.ptr;
+ func.ptr = 0;
   ::SetEvent(exit_event);
   ::SleepEx(INFINITE, TRUE);
 

Modified: trunk/boost/asio/detail/io_control.hpp
==============================================================================
--- trunk/boost/asio/detail/io_control.hpp (original)
+++ trunk/boost/asio/detail/io_control.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -46,7 +46,7 @@
   // Get the name of the IO control command.
   int name() const
   {
- return FIONBIO;
+ return static_cast<int>(FIONBIO);
   }
 
   // Set the value of the I/O control command.
@@ -96,7 +96,7 @@
   // Get the name of the IO control command.
   int name() const
   {
- return FIONREAD;
+ return static_cast<int>(FIONREAD);
   }
 
   // Set the value of the I/O control command.

Modified: trunk/boost/asio/detail/kqueue_reactor.hpp
==============================================================================
--- trunk/boost/asio/detail/kqueue_reactor.hpp (original)
+++ trunk/boost/asio/detail/kqueue_reactor.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -20,6 +20,7 @@
 
 #if defined(BOOST_ASIO_HAS_KQUEUE)
 
+#include <boost/limits.hpp>
 #include <cstddef>
 #include <sys/types.h>
 #include <sys/event.h>
@@ -108,8 +109,8 @@
 
   // Cancel any operations that are running against the descriptor and remove
   // its registration from the reactor.
- BOOST_ASIO_DECL void close_descriptor(socket_type descriptor,
- per_descriptor_data& descriptor_data);
+ BOOST_ASIO_DECL void deregister_descriptor(socket_type descriptor,
+ per_descriptor_data& descriptor_data, bool closing);
 
   // Add a new timer queue to the reactor.
   template <typename Time_Traits>
@@ -130,7 +131,8 @@
   // number of operations that have been posted or dispatched.
   template <typename Time_Traits>
   std::size_t cancel_timer(timer_queue<Time_Traits>& queue,
- typename timer_queue<Time_Traits>::per_timer_data& timer);
+ typename timer_queue<Time_Traits>::per_timer_data& timer,
+ std::size_t max_cancelled = (std::numeric_limits<std::size_t>::max)());
 
   // Run the kqueue loop.
   BOOST_ASIO_DECL void run(bool block, op_queue<operation>& ops);

Modified: trunk/boost/asio/detail/old_win_sdk_compat.hpp
==============================================================================
--- trunk/boost/asio/detail/old_win_sdk_compat.hpp (original)
+++ trunk/boost/asio/detail/old_win_sdk_compat.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -85,14 +85,6 @@
   unsigned int ipv6mr_interface;
 };
 
-#if !defined(IN6ADDR_ANY_INIT)
-# define IN6ADDR_ANY_INIT { 0 }
-#endif
-
-#if !defined(IN6ADDR_LOOPBACK_INIT)
-# define IN6ADDR_LOOPBACK_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }
-#endif
-
 struct addrinfo_emulation
 {
   int ai_flags;
@@ -201,122 +193,6 @@
 # define IPV6_LEAVE_GROUP 13
 #endif
 
-inline int IN6_IS_ADDR_UNSPECIFIED(const in6_addr_emulation* a)
-{
- return ((a->s6_addr[0] == 0)
- && (a->s6_addr[1] == 0)
- && (a->s6_addr[2] == 0)
- && (a->s6_addr[3] == 0)
- && (a->s6_addr[4] == 0)
- && (a->s6_addr[5] == 0)
- && (a->s6_addr[6] == 0)
- && (a->s6_addr[7] == 0)
- && (a->s6_addr[8] == 0)
- && (a->s6_addr[9] == 0)
- && (a->s6_addr[10] == 0)
- && (a->s6_addr[11] == 0)
- && (a->s6_addr[12] == 0)
- && (a->s6_addr[13] == 0)
- && (a->s6_addr[14] == 0)
- && (a->s6_addr[15] == 0));
-}
-
-inline int IN6_IS_ADDR_LOOPBACK(const in6_addr_emulation* a)
-{
- return ((a->s6_addr[0] == 0)
- && (a->s6_addr[1] == 0)
- && (a->s6_addr[2] == 0)
- && (a->s6_addr[3] == 0)
- && (a->s6_addr[4] == 0)
- && (a->s6_addr[5] == 0)
- && (a->s6_addr[6] == 0)
- && (a->s6_addr[7] == 0)
- && (a->s6_addr[8] == 0)
- && (a->s6_addr[9] == 0)
- && (a->s6_addr[10] == 0)
- && (a->s6_addr[11] == 0)
- && (a->s6_addr[12] == 0)
- && (a->s6_addr[13] == 0)
- && (a->s6_addr[14] == 0)
- && (a->s6_addr[15] == 1));
-}
-
-inline int IN6_IS_ADDR_MULTICAST(const in6_addr_emulation* a)
-{
- return (a->s6_addr[0] == 0xff);
-}
-
-inline int IN6_IS_ADDR_LINKLOCAL(const in6_addr_emulation* a)
-{
- return ((a->s6_addr[0] == 0xfe) && ((a->s6_addr[1] & 0xc0) == 0x80));
-}
-
-inline int IN6_IS_ADDR_SITELOCAL(const in6_addr_emulation* a)
-{
- return ((a->s6_addr[0] == 0xfe) && ((a->s6_addr[1] & 0xc0) == 0xc0));
-}
-
-inline int IN6_IS_ADDR_V4MAPPED(const in6_addr_emulation* a)
-{
- return ((a->s6_addr[0] == 0)
- && (a->s6_addr[1] == 0)
- && (a->s6_addr[2] == 0)
- && (a->s6_addr[3] == 0)
- && (a->s6_addr[4] == 0)
- && (a->s6_addr[5] == 0)
- && (a->s6_addr[6] == 0)
- && (a->s6_addr[7] == 0)
- && (a->s6_addr[8] == 0)
- && (a->s6_addr[9] == 0)
- && (a->s6_addr[10] == 0xff)
- && (a->s6_addr[11] == 0xff));
-}
-
-inline int IN6_IS_ADDR_V4COMPAT(const in6_addr_emulation* a)
-{
- return ((a->s6_addr[0] == 0)
- && (a->s6_addr[1] == 0)
- && (a->s6_addr[2] == 0)
- && (a->s6_addr[3] == 0)
- && (a->s6_addr[4] == 0)
- && (a->s6_addr[5] == 0)
- && (a->s6_addr[6] == 0)
- && (a->s6_addr[7] == 0)
- && (a->s6_addr[8] == 0)
- && (a->s6_addr[9] == 0)
- && (a->s6_addr[10] == 0xff)
- && (a->s6_addr[11] == 0xff)
- && !((a->s6_addr[12] == 0)
- && (a->s6_addr[13] == 0)
- && (a->s6_addr[14] == 0)
- && ((a->s6_addr[15] == 0) || (a->s6_addr[15] == 1))));
-}
-
-inline int IN6_IS_ADDR_MC_NODELOCAL(const in6_addr_emulation* a)
-{
- return IN6_IS_ADDR_MULTICAST(a) && ((a->s6_addr[1] & 0xf) == 1);
-}
-
-inline int IN6_IS_ADDR_MC_LINKLOCAL(const in6_addr_emulation* a)
-{
- return IN6_IS_ADDR_MULTICAST(a) && ((a->s6_addr[1] & 0xf) == 2);
-}
-
-inline int IN6_IS_ADDR_MC_SITELOCAL(const in6_addr_emulation* a)
-{
- return IN6_IS_ADDR_MULTICAST(a) && ((a->s6_addr[1] & 0xf) == 5);
-}
-
-inline int IN6_IS_ADDR_MC_ORGLOCAL(const in6_addr_emulation* a)
-{
- return IN6_IS_ADDR_MULTICAST(a) && ((a->s6_addr[1] & 0xf) == 8);
-}
-
-inline int IN6_IS_ADDR_MC_GLOBAL(const in6_addr_emulation* a)
-{
- return IN6_IS_ADDR_MULTICAST(a) && ((a->s6_addr[1] & 0xf) == 0xe);
-}
-
 } // namespace detail
 } // namespace asio
 } // namespace boost

Modified: trunk/boost/asio/detail/posix_thread.hpp
==============================================================================
--- trunk/boost/asio/detail/posix_thread.hpp (original)
+++ trunk/boost/asio/detail/posix_thread.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -39,7 +39,7 @@
 public:
   // Constructor.
   template <typename Function>
- posix_thread(Function f)
+ posix_thread(Function f, unsigned int = 0)
     : joined_(false)
   {
     start_thread(new func<Function>(f));

Modified: trunk/boost/asio/detail/reactive_descriptor_service.hpp
==============================================================================
--- trunk/boost/asio/detail/reactive_descriptor_service.hpp (original)
+++ trunk/boost/asio/detail/reactive_descriptor_service.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -42,7 +42,7 @@
 {
 public:
   // The native type of a descriptor.
- typedef int native_type;
+ typedef int native_handle_type;
 
   // The implementation type of the descriptor.
   class implementation_type
@@ -85,7 +85,8 @@
 
   // Assign a native descriptor to a descriptor implementation.
   BOOST_ASIO_DECL boost::system::error_code assign(implementation_type& impl,
- const native_type& native_descriptor, boost::system::error_code& ec);
+ const native_handle_type& native_descriptor,
+ boost::system::error_code& ec);
 
   // Determine whether the descriptor is open.
   bool is_open(const implementation_type& impl) const
@@ -98,11 +99,14 @@
       boost::system::error_code& ec);
 
   // Get the native descriptor representation.
- native_type native(const implementation_type& impl) const
+ native_handle_type native_handle(const implementation_type& impl) const
   {
     return impl.descriptor_;
   }
 
+ // Release ownership of the native descriptor representation.
+ BOOST_ASIO_DECL native_handle_type release(implementation_type& impl);
+
   // Cancel all operations associated with the descriptor.
   BOOST_ASIO_DECL boost::system::error_code cancel(implementation_type& impl,
       boost::system::error_code& ec);
@@ -117,6 +121,36 @@
     return ec;
   }
 
+ // Gets the non-blocking mode of the descriptor.
+ bool non_blocking(const implementation_type& impl) const
+ {
+ return (impl.state_ & descriptor_ops::user_set_non_blocking) != 0;
+ }
+
+ // Sets the non-blocking mode of the descriptor.
+ boost::system::error_code non_blocking(implementation_type& impl,
+ bool mode, boost::system::error_code& ec)
+ {
+ descriptor_ops::set_user_non_blocking(
+ impl.descriptor_, impl.state_, mode, ec);
+ return ec;
+ }
+
+ // Gets the non-blocking mode of the native descriptor implementation.
+ bool native_non_blocking(const implementation_type& impl) const
+ {
+ return (impl.state_ & descriptor_ops::internal_non_blocking) != 0;
+ }
+
+ // Sets the non-blocking mode of the native descriptor implementation.
+ boost::system::error_code native_non_blocking(implementation_type& impl,
+ bool mode, boost::system::error_code& ec)
+ {
+ descriptor_ops::set_internal_non_blocking(
+ impl.descriptor_, impl.state_, mode, ec);
+ return ec;
+ }
+
   // Write some data to the descriptor.
   template <typename ConstBufferSequence>
   size_t write_some(implementation_type& impl,
@@ -143,7 +177,7 @@
   // lifetime of the asynchronous operation.
   template <typename ConstBufferSequence, typename Handler>
   void async_write_some(implementation_type& impl,
- const ConstBufferSequence& buffers, Handler handler)
+ const ConstBufferSequence& buffers, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef descriptor_write_op<ConstBufferSequence, Handler> op;
@@ -161,7 +195,7 @@
   // Start an asynchronous wait until data can be written without blocking.
   template <typename Handler>
   void async_write_some(implementation_type& impl,
- const null_buffers&, Handler handler)
+ const null_buffers&, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef reactive_null_buffers_op<Handler> op;
@@ -200,7 +234,7 @@
   // valid for the lifetime of the asynchronous operation.
   template <typename MutableBufferSequence, typename Handler>
   void async_read_some(implementation_type& impl,
- const MutableBufferSequence& buffers, Handler handler)
+ const MutableBufferSequence& buffers, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef descriptor_read_op<MutableBufferSequence, Handler> op;
@@ -218,7 +252,7 @@
   // Wait until data can be read without blocking.
   template <typename Handler>
   void async_read_some(implementation_type& impl,
- const null_buffers&, Handler handler)
+ const null_buffers&, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef reactive_null_buffers_op<Handler> op;
@@ -234,7 +268,7 @@
 private:
   // Start the asynchronous operation.
   BOOST_ASIO_DECL void start_op(implementation_type& impl, int op_type,
- reactor_op* op, bool non_blocking, bool noop);
+ reactor_op* op, bool is_non_blocking, bool noop);
 
   // The selector that performs event demultiplexing for the service.
   reactor& reactor_;

Modified: trunk/boost/asio/detail/reactive_null_buffers_op.hpp
==============================================================================
--- trunk/boost/asio/detail/reactive_null_buffers_op.hpp (original)
+++ trunk/boost/asio/detail/reactive_null_buffers_op.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -34,10 +34,10 @@
 public:
   BOOST_ASIO_DEFINE_HANDLER_PTR(reactive_null_buffers_op);
 
- reactive_null_buffers_op(Handler handler)
+ reactive_null_buffers_op(Handler& handler)
     : reactor_op(&reactive_null_buffers_op::do_perform,
         &reactive_null_buffers_op::do_complete),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler))
   {
   }
 

Modified: trunk/boost/asio/detail/reactive_serial_port_service.hpp
==============================================================================
--- trunk/boost/asio/detail/reactive_serial_port_service.hpp (original)
+++ trunk/boost/asio/detail/reactive_serial_port_service.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -39,7 +39,7 @@
 {
 public:
   // The native type of a serial port.
- typedef reactive_descriptor_service::native_type native_type;
+ typedef reactive_descriptor_service::native_handle_type native_handle_type;
 
   // The implementation type of the serial port.
   typedef reactive_descriptor_service::implementation_type implementation_type;
@@ -68,7 +68,8 @@
 
   // Assign a native descriptor to a serial port implementation.
   boost::system::error_code assign(implementation_type& impl,
- const native_type& native_descriptor, boost::system::error_code& ec)
+ const native_handle_type& native_descriptor,
+ boost::system::error_code& ec)
   {
     return descriptor_service_.assign(impl, native_descriptor, ec);
   }
@@ -87,9 +88,9 @@
   }
 
   // Get the native serial port representation.
- native_type native(implementation_type& impl)
+ native_handle_type native_handle(implementation_type& impl)
   {
- return descriptor_service_.native(impl);
+ return descriptor_service_.native_handle(impl);
   }
 
   // Cancel all operations associated with the serial port.
@@ -125,7 +126,7 @@
   {
     errno = 0;
     descriptor_ops::error_wrapper(::tcsendbreak(
- descriptor_service_.native(impl), 0), ec);
+ descriptor_service_.native_handle(impl), 0), ec);
     return ec;
   }
 
@@ -141,7 +142,7 @@
   // lifetime of the asynchronous operation.
   template <typename ConstBufferSequence, typename Handler>
   void async_write_some(implementation_type& impl,
- const ConstBufferSequence& buffers, Handler handler)
+ const ConstBufferSequence& buffers, Handler& handler)
   {
     descriptor_service_.async_write_some(impl, buffers, handler);
   }
@@ -158,7 +159,7 @@
   // valid for the lifetime of the asynchronous operation.
   template <typename MutableBufferSequence, typename Handler>
   void async_read_some(implementation_type& impl,
- const MutableBufferSequence& buffers, Handler handler)
+ const MutableBufferSequence& buffers, Handler& handler)
   {
     descriptor_service_.async_read_some(impl, buffers, handler);
   }

Modified: trunk/boost/asio/detail/reactive_socket_accept_op.hpp
==============================================================================
--- trunk/boost/asio/detail/reactive_socket_accept_op.hpp (original)
+++ trunk/boost/asio/detail/reactive_socket_accept_op.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -87,10 +87,10 @@
 
   reactive_socket_accept_op(socket_type socket,
       socket_ops::state_type state, Socket& peer, const Protocol& protocol,
- typename Protocol::endpoint* peer_endpoint, Handler handler)
+ typename Protocol::endpoint* peer_endpoint, Handler& handler)
     : reactive_socket_accept_op_base<Socket, Protocol>(socket, state, peer,
         protocol, peer_endpoint, &reactive_socket_accept_op::do_complete),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler))
   {
   }
 

Modified: trunk/boost/asio/detail/reactive_socket_connect_op.hpp
==============================================================================
--- trunk/boost/asio/detail/reactive_socket_connect_op.hpp (original)
+++ trunk/boost/asio/detail/reactive_socket_connect_op.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -56,10 +56,10 @@
 public:
   BOOST_ASIO_DEFINE_HANDLER_PTR(reactive_socket_connect_op);
 
- reactive_socket_connect_op(socket_type socket, Handler handler)
+ reactive_socket_connect_op(socket_type socket, Handler& handler)
     : reactive_socket_connect_op_base(socket,
         &reactive_socket_connect_op::do_complete),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler))
   {
   }
 

Modified: trunk/boost/asio/detail/reactive_socket_recv_op.hpp
==============================================================================
--- trunk/boost/asio/detail/reactive_socket_recv_op.hpp (original)
+++ trunk/boost/asio/detail/reactive_socket_recv_op.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -74,10 +74,10 @@
 
   reactive_socket_recv_op(socket_type socket,
       socket_ops::state_type state, const MutableBufferSequence& buffers,
- socket_base::message_flags flags, Handler handler)
+ socket_base::message_flags flags, Handler& handler)
     : reactive_socket_recv_op_base<MutableBufferSequence>(socket, state,
         buffers, flags, &reactive_socket_recv_op::do_complete),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler))
   {
   }
 

Modified: trunk/boost/asio/detail/reactive_socket_recvfrom_op.hpp
==============================================================================
--- trunk/boost/asio/detail/reactive_socket_recvfrom_op.hpp (original)
+++ trunk/boost/asio/detail/reactive_socket_recvfrom_op.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -82,11 +82,11 @@
 
   reactive_socket_recvfrom_op(socket_type socket, int protocol_type,
       const MutableBufferSequence& buffers, Endpoint& endpoint,
- socket_base::message_flags flags, Handler handler)
+ socket_base::message_flags flags, Handler& handler)
     : reactive_socket_recvfrom_op_base<MutableBufferSequence, Endpoint>(
         socket, protocol_type, buffers, endpoint, flags,
         &reactive_socket_recvfrom_op::do_complete),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler))
   {
   }
 

Added: trunk/boost/asio/detail/reactive_socket_recvmsg_op.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/asio/detail/reactive_socket_recvmsg_op.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -0,0 +1,122 @@
+//
+// detail/reactive_socket_recvmsg_op.hpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// 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)
+//
+
+#ifndef BOOST_ASIO_DETAIL_REACTIVE_SOCKET_RECVMSG_OP_HPP
+#define BOOST_ASIO_DETAIL_REACTIVE_SOCKET_RECVMSG_OP_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
+
+#include <boost/asio/detail/config.hpp>
+#include <boost/utility/addressof.hpp>
+#include <boost/asio/detail/bind_handler.hpp>
+#include <boost/asio/detail/buffer_sequence_adapter.hpp>
+#include <boost/asio/detail/fenced_block.hpp>
+#include <boost/asio/detail/reactor_op.hpp>
+#include <boost/asio/detail/socket_ops.hpp>
+#include <boost/asio/socket_base.hpp>
+
+#include <boost/asio/detail/push_options.hpp>
+
+namespace boost {
+namespace asio {
+namespace detail {
+
+template <typename MutableBufferSequence>
+class reactive_socket_recvmsg_op_base : public reactor_op
+{
+public:
+ reactive_socket_recvmsg_op_base(socket_type socket,
+ const MutableBufferSequence& buffers, socket_base::message_flags in_flags,
+ socket_base::message_flags& out_flags, func_type complete_func)
+ : reactor_op(&reactive_socket_recvmsg_op_base::do_perform, complete_func),
+ socket_(socket),
+ buffers_(buffers),
+ in_flags_(in_flags),
+ out_flags_(out_flags)
+ {
+ }
+
+ static bool do_perform(reactor_op* base)
+ {
+ reactive_socket_recvmsg_op_base* o(
+ static_cast<reactive_socket_recvmsg_op_base*>(base));
+
+ buffer_sequence_adapter<boost::asio::mutable_buffer,
+ MutableBufferSequence> bufs(o->buffers_);
+
+ return socket_ops::non_blocking_recvmsg(o->socket_,
+ bufs.buffers(), bufs.count(),
+ o->in_flags_, o->out_flags_,
+ o->ec_, o->bytes_transferred_);
+ }
+
+private:
+ socket_type socket_;
+ MutableBufferSequence buffers_;
+ socket_base::message_flags in_flags_;
+ socket_base::message_flags& out_flags_;
+};
+
+template <typename MutableBufferSequence, typename Handler>
+class reactive_socket_recvmsg_op :
+ public reactive_socket_recvmsg_op_base<MutableBufferSequence>
+{
+public:
+ BOOST_ASIO_DEFINE_HANDLER_PTR(reactive_socket_recvmsg_op);
+
+ reactive_socket_recvmsg_op(socket_type socket,
+ const MutableBufferSequence& buffers, socket_base::message_flags in_flags,
+ socket_base::message_flags& out_flags, Handler& handler)
+ : reactive_socket_recvmsg_op_base<MutableBufferSequence>(socket, buffers,
+ in_flags, out_flags, &reactive_socket_recvmsg_op::do_complete),
+ handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler))
+ {
+ }
+
+ static void do_complete(io_service_impl* owner, operation* base,
+ boost::system::error_code /*ec*/, std::size_t /*bytes_transferred*/)
+ {
+ // Take ownership of the handler object.
+ reactive_socket_recvmsg_op* o(
+ static_cast<reactive_socket_recvmsg_op*>(base));
+ ptr p = { boost::addressof(o->handler_), o, o };
+
+ // Make a copy of the handler so that the memory can be deallocated before
+ // the upcall is made. Even if we're not about to make an upcall, a
+ // sub-object of the handler may be the true owner of the memory associated
+ // with the handler. Consequently, a local copy of the handler is required
+ // to ensure that any owning sub-object remains valid until after we have
+ // deallocated the memory here.
+ detail::binder2<Handler, boost::system::error_code, std::size_t>
+ handler(o->handler_, o->ec_, o->bytes_transferred_);
+ p.h = boost::addressof(handler.handler_);
+ p.reset();
+
+ // Make the upcall if required.
+ if (owner)
+ {
+ boost::asio::detail::fenced_block b;
+ boost_asio_handler_invoke_helpers::invoke(handler, handler.handler_);
+ }
+ }
+
+private:
+ Handler handler_;
+};
+
+} // namespace detail
+} // namespace asio
+} // namespace boost
+
+#include <boost/asio/detail/pop_options.hpp>
+
+#endif // BOOST_ASIO_DETAIL_REACTIVE_SOCKET_RECVMSG_OP_HPP

Modified: trunk/boost/asio/detail/reactive_socket_send_op.hpp
==============================================================================
--- trunk/boost/asio/detail/reactive_socket_send_op.hpp (original)
+++ trunk/boost/asio/detail/reactive_socket_send_op.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -71,10 +71,10 @@
 
   reactive_socket_send_op(socket_type socket,
       const ConstBufferSequence& buffers,
- socket_base::message_flags flags, Handler handler)
+ socket_base::message_flags flags, Handler& handler)
     : reactive_socket_send_op_base<ConstBufferSequence>(socket,
         buffers, flags, &reactive_socket_send_op::do_complete),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler))
   {
   }
 

Modified: trunk/boost/asio/detail/reactive_socket_sendto_op.hpp
==============================================================================
--- trunk/boost/asio/detail/reactive_socket_sendto_op.hpp (original)
+++ trunk/boost/asio/detail/reactive_socket_sendto_op.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -74,10 +74,10 @@
 
   reactive_socket_sendto_op(socket_type socket,
       const ConstBufferSequence& buffers, const Endpoint& endpoint,
- socket_base::message_flags flags, Handler handler)
+ socket_base::message_flags flags, Handler& handler)
     : reactive_socket_sendto_op_base<ConstBufferSequence, Endpoint>(socket,
         buffers, endpoint, flags, &reactive_socket_sendto_op::do_complete),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler))
   {
   }
 

Modified: trunk/boost/asio/detail/reactive_socket_service.hpp
==============================================================================
--- trunk/boost/asio/detail/reactive_socket_service.hpp (original)
+++ trunk/boost/asio/detail/reactive_socket_service.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -56,7 +56,7 @@
   typedef typename Protocol::endpoint endpoint_type;
 
   // The native type of a socket.
- typedef socket_type native_type;
+ typedef socket_type native_handle_type;
 
   // The implementation type of the socket.
   struct implementation_type :
@@ -90,7 +90,7 @@
 
   // Assign a native socket to a socket implementation.
   boost::system::error_code assign(implementation_type& impl,
- const protocol_type& protocol, const native_type& native_socket,
+ const protocol_type& protocol, const native_handle_type& native_socket,
       boost::system::error_code& ec)
   {
     if (!do_assign(impl, protocol.type(), native_socket, ec))
@@ -99,7 +99,7 @@
   }
 
   // Get the native socket representation.
- native_type native(implementation_type& impl)
+ native_handle_type native_handle(implementation_type& impl)
   {
     return impl.socket_;
   }
@@ -194,7 +194,7 @@
   void async_send_to(implementation_type& impl,
       const ConstBufferSequence& buffers,
       const endpoint_type& destination, socket_base::message_flags flags,
- Handler handler)
+ Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef reactive_socket_sendto_op<ConstBufferSequence,
@@ -211,7 +211,7 @@
   // Start an asynchronous wait until data can be sent without blocking.
   template <typename Handler>
   void async_send_to(implementation_type& impl, const null_buffers&,
- const endpoint_type&, socket_base::message_flags, Handler handler)
+ const endpoint_type&, socket_base::message_flags, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef reactive_null_buffers_op<Handler> op;
@@ -266,7 +266,7 @@
   template <typename MutableBufferSequence, typename Handler>
   void async_receive_from(implementation_type& impl,
       const MutableBufferSequence& buffers, endpoint_type& sender_endpoint,
- socket_base::message_flags flags, Handler handler)
+ socket_base::message_flags flags, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef reactive_socket_recvfrom_op<MutableBufferSequence,
@@ -274,8 +274,8 @@
     typename op::ptr p = { boost::addressof(handler),
       boost_asio_handler_alloc_helpers::allocate(
         sizeof(op), handler), 0 };
- int protocol_type = impl.protocol_.type();
- p.p = new (p.v) op(impl.socket_, protocol_type,
+ int protocol = impl.protocol_.type();
+ p.p = new (p.v) op(impl.socket_, protocol,
         buffers, sender_endpoint, flags, handler);
 
     start_op(impl,
@@ -289,7 +289,7 @@
   template <typename Handler>
   void async_receive_from(implementation_type& impl,
       const null_buffers&, endpoint_type& sender_endpoint,
- socket_base::message_flags flags, Handler handler)
+ socket_base::message_flags flags, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef reactive_null_buffers_op<Handler> op;
@@ -341,7 +341,7 @@
   // must be valid until the accept's handler is invoked.
   template <typename Socket, typename Handler>
   void async_accept(implementation_type& impl, Socket& peer,
- endpoint_type* peer_endpoint, Handler handler)
+ endpoint_type* peer_endpoint, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef reactive_socket_accept_op<Socket, Protocol, Handler> op;
@@ -367,7 +367,7 @@
   // Start an asynchronous connect.
   template <typename Handler>
   void async_connect(implementation_type& impl,
- const endpoint_type& peer_endpoint, Handler handler)
+ const endpoint_type& peer_endpoint, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef reactive_socket_connect_op<Handler> op;

Modified: trunk/boost/asio/detail/reactive_socket_service_base.hpp
==============================================================================
--- trunk/boost/asio/detail/reactive_socket_service_base.hpp (original)
+++ trunk/boost/asio/detail/reactive_socket_service_base.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -27,6 +27,7 @@
 #include <boost/asio/detail/buffer_sequence_adapter.hpp>
 #include <boost/asio/detail/reactive_null_buffers_op.hpp>
 #include <boost/asio/detail/reactive_socket_recv_op.hpp>
+#include <boost/asio/detail/reactive_socket_recvmsg_op.hpp>
 #include <boost/asio/detail/reactive_socket_send_op.hpp>
 #include <boost/asio/detail/reactor.hpp>
 #include <boost/asio/detail/reactor_op.hpp>
@@ -44,7 +45,7 @@
 {
 public:
   // The native type of a socket.
- typedef socket_type native_type;
+ typedef socket_type native_handle_type;
 
   // The implementation type of the socket.
   struct base_implementation_type
@@ -83,7 +84,7 @@
       base_implementation_type& impl, boost::system::error_code& ec);
 
   // Get the native socket representation.
- native_type native(base_implementation_type& impl)
+ native_handle_type native_handle(base_implementation_type& impl)
   {
     return impl.socket_;
   }
@@ -124,7 +125,35 @@
     return ec;
   }
 
- /// Disable sends or receives on the socket.
+ // Gets the non-blocking mode of the socket.
+ bool non_blocking(const base_implementation_type& impl) const
+ {
+ return (impl.state_ & socket_ops::user_set_non_blocking) != 0;
+ }
+
+ // Sets the non-blocking mode of the socket.
+ boost::system::error_code non_blocking(base_implementation_type& impl,
+ bool mode, boost::system::error_code& ec)
+ {
+ socket_ops::set_user_non_blocking(impl.socket_, impl.state_, mode, ec);
+ return ec;
+ }
+
+ // Gets the non-blocking mode of the native socket implementation.
+ bool native_non_blocking(const base_implementation_type& impl) const
+ {
+ return (impl.state_ & socket_ops::internal_non_blocking) != 0;
+ }
+
+ // Sets the non-blocking mode of the native socket implementation.
+ boost::system::error_code native_non_blocking(base_implementation_type& impl,
+ bool mode, boost::system::error_code& ec)
+ {
+ socket_ops::set_internal_non_blocking(impl.socket_, impl.state_, mode, ec);
+ return ec;
+ }
+
+ // Disable sends or receives on the socket.
   boost::system::error_code shutdown(base_implementation_type& impl,
       socket_base::shutdown_type what, boost::system::error_code& ec)
   {
@@ -160,7 +189,7 @@
   template <typename ConstBufferSequence, typename Handler>
   void async_send(base_implementation_type& impl,
       const ConstBufferSequence& buffers,
- socket_base::message_flags flags, Handler handler)
+ socket_base::message_flags flags, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef reactive_socket_send_op<ConstBufferSequence, Handler> op;
@@ -179,7 +208,7 @@
   // Start an asynchronous wait until data can be sent without blocking.
   template <typename Handler>
   void async_send(base_implementation_type& impl, const null_buffers&,
- socket_base::message_flags, Handler handler)
+ socket_base::message_flags, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef reactive_null_buffers_op<Handler> op;
@@ -220,7 +249,7 @@
   template <typename MutableBufferSequence, typename Handler>
   void async_receive(base_implementation_type& impl,
       const MutableBufferSequence& buffers,
- socket_base::message_flags flags, Handler handler)
+ socket_base::message_flags flags, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef reactive_socket_recv_op<MutableBufferSequence, Handler> op;
@@ -242,7 +271,7 @@
   // Wait until data can be received without blocking.
   template <typename Handler>
   void async_receive(base_implementation_type& impl, const null_buffers&,
- socket_base::message_flags flags, Handler handler)
+ socket_base::message_flags flags, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef reactive_null_buffers_op<Handler> op;
@@ -258,6 +287,81 @@
     p.v = p.p = 0;
   }
 
+ // Receive some data with associated flags. Returns the number of bytes
+ // received.
+ template <typename MutableBufferSequence>
+ size_t receive_with_flags(base_implementation_type& impl,
+ const MutableBufferSequence& buffers,
+ socket_base::message_flags in_flags,
+ socket_base::message_flags& out_flags, boost::system::error_code& ec)
+ {
+ buffer_sequence_adapter<boost::asio::mutable_buffer,
+ MutableBufferSequence> bufs(buffers);
+
+ return socket_ops::sync_recvmsg(impl.socket_, impl.state_,
+ bufs.buffers(), bufs.count(), in_flags, out_flags, ec);
+ }
+
+ // Wait until data can be received without blocking.
+ size_t receive_with_flags(base_implementation_type& impl,
+ const null_buffers&, socket_base::message_flags,
+ socket_base::message_flags& out_flags, boost::system::error_code& ec)
+ {
+ // Wait for socket to become ready.
+ socket_ops::poll_read(impl.socket_, ec);
+
+ // Clear out_flags, since we cannot give it any other sensible value when
+ // performing a null_buffers operation.
+ out_flags = 0;
+
+ return 0;
+ }
+
+ // Start an asynchronous receive. The buffer for the data being received
+ // must be valid for the lifetime of the asynchronous operation.
+ template <typename MutableBufferSequence, typename Handler>
+ void async_receive_with_flags(base_implementation_type& impl,
+ const MutableBufferSequence& buffers, socket_base::message_flags in_flags,
+ socket_base::message_flags& out_flags, Handler& handler)
+ {
+ // Allocate and construct an operation to wrap the handler.
+ typedef reactive_socket_recvmsg_op<MutableBufferSequence, Handler> op;
+ typename op::ptr p = { boost::addressof(handler),
+ boost_asio_handler_alloc_helpers::allocate(
+ sizeof(op), handler), 0 };
+ p.p = new (p.v) op(impl.socket_, buffers, in_flags, out_flags, handler);
+
+ start_op(impl,
+ (in_flags & socket_base::message_out_of_band)
+ ? reactor::except_op : reactor::read_op,
+ p.p, (in_flags & socket_base::message_out_of_band) == 0, false);
+ p.v = p.p = 0;
+ }
+
+ // Wait until data can be received without blocking.
+ template <typename Handler>
+ void async_receive_with_flags(base_implementation_type& impl,
+ const null_buffers&, socket_base::message_flags in_flags,
+ socket_base::message_flags& out_flags, Handler& handler)
+ {
+ // Allocate and construct an operation to wrap the handler.
+ typedef reactive_null_buffers_op<Handler> op;
+ typename op::ptr p = { boost::addressof(handler),
+ boost_asio_handler_alloc_helpers::allocate(
+ sizeof(op), handler), 0 };
+ p.p = new (p.v) op(handler);
+
+ // Clear out_flags, since we cannot give it any other sensible value when
+ // performing a null_buffers operation.
+ out_flags = 0;
+
+ start_op(impl,
+ (in_flags & socket_base::message_out_of_band)
+ ? reactor::except_op : reactor::read_op,
+ p.p, false, false);
+ p.v = p.p = 0;
+ }
+
 protected:
   // Open a new socket implementation.
   BOOST_ASIO_DECL boost::system::error_code do_open(
@@ -267,11 +371,11 @@
   // Assign a native socket to a socket implementation.
   BOOST_ASIO_DECL boost::system::error_code do_assign(
       base_implementation_type& impl, int type,
- const native_type& native_socket, boost::system::error_code& ec);
+ const native_handle_type& native_socket, boost::system::error_code& ec);
 
   // Start the asynchronous read or write operation.
   BOOST_ASIO_DECL void start_op(base_implementation_type& impl, int op_type,
- reactor_op* op, bool non_blocking, bool noop);
+ reactor_op* op, bool is_non_blocking, bool noop);
 
   // Start the asynchronous accept operation.
   BOOST_ASIO_DECL void start_accept_op(base_implementation_type& impl,

Modified: trunk/boost/asio/detail/resolve_endpoint_op.hpp
==============================================================================
--- trunk/boost/asio/detail/resolve_endpoint_op.hpp (original)
+++ trunk/boost/asio/detail/resolve_endpoint_op.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -43,12 +43,12 @@
   typedef boost::asio::ip::basic_resolver_iterator<Protocol> iterator_type;
 
   resolve_endpoint_op(socket_ops::weak_cancel_token_type cancel_token,
- const endpoint_type& endpoint, io_service_impl& ios, Handler handler)
+ const endpoint_type& endpoint, io_service_impl& ios, Handler& handler)
     : operation(&resolve_endpoint_op::do_complete),
       cancel_token_(cancel_token),
       endpoint_(endpoint),
       io_service_impl_(ios),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler))
   {
   }
 

Modified: trunk/boost/asio/detail/resolve_op.hpp
==============================================================================
--- trunk/boost/asio/detail/resolve_op.hpp (original)
+++ trunk/boost/asio/detail/resolve_op.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -44,12 +44,12 @@
   typedef boost::asio::ip::basic_resolver_iterator<Protocol> iterator_type;
 
   resolve_op(socket_ops::weak_cancel_token_type cancel_token,
- const query_type& query, io_service_impl& ios, Handler handler)
+ const query_type& query, io_service_impl& ios, Handler& handler)
     : operation(&resolve_op::do_complete),
       cancel_token_(cancel_token),
       query_(query),
       io_service_impl_(ios),
- handler_(handler),
+ handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)),
       addrinfo_(0)
   {
   }

Modified: trunk/boost/asio/detail/resolver_service.hpp
==============================================================================
--- trunk/boost/asio/detail/resolver_service.hpp (original)
+++ trunk/boost/asio/detail/resolver_service.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -67,8 +67,8 @@
 
   // Asynchronously resolve a query to a list of entries.
   template <typename Handler>
- void async_resolve(implementation_type& impl, const query_type& query,
- Handler handler)
+ void async_resolve(implementation_type& impl,
+ const query_type& query, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef resolve_op<Protocol, Handler> op;
@@ -97,8 +97,8 @@
 
   // Asynchronously resolve an endpoint to a list of entries.
   template <typename Handler>
- void async_resolve(implementation_type& impl, const endpoint_type& endpoint,
- Handler handler)
+ void async_resolve(implementation_type& impl,
+ const endpoint_type& endpoint, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef resolve_endpoint_op<Protocol, Handler> op;

Modified: trunk/boost/asio/detail/select_reactor.hpp
==============================================================================
--- trunk/boost/asio/detail/select_reactor.hpp (original)
+++ trunk/boost/asio/detail/select_reactor.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -22,6 +22,7 @@
       && !defined(BOOST_ASIO_HAS_EPOLL) \
       && !defined(BOOST_ASIO_HAS_KQUEUE))
 
+#include <boost/limits.hpp>
 #include <cstddef>
 #include <boost/asio/detail/mutex.hpp>
 #include <boost/asio/detail/op_queue.hpp>
@@ -51,10 +52,10 @@
 {
 public:
 #if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
- enum { read_op = 0, write_op = 1, except_op = 2,
+ enum op_types { read_op = 0, write_op = 1, except_op = 2,
     max_select_ops = 3, connect_op = 3, max_ops = 4 };
 #else // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
- enum { read_op = 0, write_op = 1, except_op = 2,
+ enum op_types { read_op = 0, write_op = 1, except_op = 2,
     max_select_ops = 3, connect_op = 1, max_ops = 3 };
 #endif // defined(BOOST_WINDOWS) || defined(__CYGWIN__)
 
@@ -97,8 +98,8 @@
 
   // Cancel any operations that are running against the descriptor and remove
   // its registration from the reactor.
- BOOST_ASIO_DECL void close_descriptor(socket_type descriptor,
- per_descriptor_data&);
+ BOOST_ASIO_DECL void deregister_descriptor(socket_type descriptor,
+ per_descriptor_data&, bool closing);
 
   // Add a new timer queue to the reactor.
   template <typename Time_Traits>
@@ -119,7 +120,8 @@
   // number of operations that have been posted or dispatched.
   template <typename Time_Traits>
   std::size_t cancel_timer(timer_queue<Time_Traits>& queue,
- typename timer_queue<Time_Traits>::per_timer_data& timer);
+ typename timer_queue<Time_Traits>::per_timer_data& timer,
+ std::size_t max_cancelled = (std::numeric_limits<std::size_t>::max)());
 
   // Run select once until interrupted or events are ready to be dispatched.
   BOOST_ASIO_DECL void run(bool block, op_queue<operation>& ops);

Modified: trunk/boost/asio/detail/socket_ops.hpp
==============================================================================
--- trunk/boost/asio/detail/socket_ops.hpp (original)
+++ trunk/boost/asio/detail/socket_ops.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -51,7 +51,10 @@
   stream_oriented = 16,
 
   // The socket is datagram-oriented.
- datagram_oriented = 32
+ datagram_oriented = 32,
+
+ // The socket may have been dup()-ed.
+ possible_dup = 64
 };
 
 typedef unsigned char state_type;
@@ -88,8 +91,11 @@
 BOOST_ASIO_DECL int close(socket_type s, state_type& state,
     bool destruction, boost::system::error_code& ec);
 
+BOOST_ASIO_DECL bool set_user_non_blocking(socket_type s,
+ state_type& state, bool value, boost::system::error_code& ec);
+
 BOOST_ASIO_DECL bool set_internal_non_blocking(socket_type s,
- state_type& state, boost::system::error_code& ec);
+ state_type& state, bool value, boost::system::error_code& ec);
 
 BOOST_ASIO_DECL int shutdown(socket_type s,
     int what, boost::system::error_code& ec);
@@ -166,6 +172,27 @@
 
 #endif // defined(BOOST_ASIO_HAS_IOCP)
 
+BOOST_ASIO_DECL int recvmsg(socket_type s, buf* bufs, size_t count,
+ int in_flags, int& out_flags, boost::system::error_code& ec);
+
+BOOST_ASIO_DECL size_t sync_recvmsg(socket_type s, state_type state,
+ buf* bufs, size_t count, int in_flags, int& out_flags,
+ boost::system::error_code& ec);
+
+#if defined(BOOST_ASIO_HAS_IOCP)
+
+BOOST_ASIO_DECL void complete_iocp_recvmsg(
+ const weak_cancel_token_type& cancel_token,
+ boost::system::error_code& ec);
+
+#else // defined(BOOST_ASIO_HAS_IOCP)
+
+BOOST_ASIO_DECL bool non_blocking_recvmsg(socket_type s,
+ buf* bufs, size_t count, int in_flags, int& out_flags,
+ boost::system::error_code& ec, size_t& bytes_transferred);
+
+#endif // defined(BOOST_ASIO_HAS_IOCP)
+
 BOOST_ASIO_DECL int send(socket_type s, const buf* bufs,
     size_t count, int flags, boost::system::error_code& ec);
 

Modified: trunk/boost/asio/detail/socket_types.hpp
==============================================================================
--- trunk/boost/asio/detail/socket_types.hpp (original)
+++ trunk/boost/asio/detail/socket_types.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -113,6 +113,7 @@
 const int message_peek = MSG_PEEK;
 const int message_out_of_band = MSG_OOB;
 const int message_do_not_route = MSG_DONTROUTE;
+const int message_end_of_record = 0; // Not supported on Windows.
 # if defined (_WIN32_WINNT)
 const int max_iov_len = 64;
 # else
@@ -156,6 +157,7 @@
 const int message_peek = MSG_PEEK;
 const int message_out_of_band = MSG_OOB;
 const int message_do_not_route = MSG_DONTROUTE;
+const int message_end_of_record = MSG_EOR;
 # if defined(IOV_MAX)
 const int max_iov_len = IOV_MAX;
 # else

Modified: trunk/boost/asio/detail/strand_service.hpp
==============================================================================
--- trunk/boost/asio/detail/strand_service.hpp (original)
+++ trunk/boost/asio/detail/strand_service.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -80,11 +80,11 @@
 
   // Request the io_service to invoke the given handler.
   template <typename Handler>
- void dispatch(implementation_type& impl, Handler handler);
+ void dispatch(implementation_type& impl, Handler& handler);
 
   // Request the io_service to invoke the given handler and return immediately.
   template <typename Handler>
- void post(implementation_type& impl, Handler handler);
+ void post(implementation_type& impl, Handler& handler);
 
 private:
   BOOST_ASIO_DECL static void do_complete(io_service_impl* owner,

Modified: trunk/boost/asio/detail/task_io_service.hpp
==============================================================================
--- trunk/boost/asio/detail/task_io_service.hpp (original)
+++ trunk/boost/asio/detail/task_io_service.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -67,6 +67,9 @@
   // Interrupt the event processing loop.
   BOOST_ASIO_DECL void stop();
 
+ // Determine whether the io_service is stopped.
+ BOOST_ASIO_DECL bool stopped() const;
+
   // Reset in preparation for a subsequent run invocation.
   BOOST_ASIO_DECL void reset();
 
@@ -85,11 +88,11 @@
 
   // Request invocation of the given handler.
   template <typename Handler>
- void dispatch(Handler handler);
+ void dispatch(Handler& handler);
 
   // Request invocation of the given handler and return immediately.
   template <typename Handler>
- void post(Handler handler);
+ void post(Handler& handler);
 
   // Request invocation of the given operation and return immediately. Assumes
   // that work_started() has not yet been called for the operation.
@@ -132,7 +135,7 @@
   struct work_finished_on_block_exit;
 
   // Mutex to protect access to internal data.
- mutex mutex_;
+ mutable mutex mutex_;
 
   // The task to be run by this service.
   reactor* task_;

Modified: trunk/boost/asio/detail/timer_queue.hpp
==============================================================================
--- trunk/boost/asio/detail/timer_queue.hpp (original)
+++ trunk/boost/asio/detail/timer_queue.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -183,20 +183,23 @@
     heap_.clear();
   }
 
- // Cancel and dequeue the timers with the given token.
- std::size_t cancel_timer(per_timer_data& timer, op_queue<operation>& ops)
+ // Cancel and dequeue operations for the given timer.
+ std::size_t cancel_timer(per_timer_data& timer, op_queue<operation>& ops,
+ std::size_t max_cancelled = (std::numeric_limits<std::size_t>::max)())
   {
     std::size_t num_cancelled = 0;
     if (timer.prev_ != 0 || &timer == timers_)
     {
- while (timer_op* op = timer.op_queue_.front())
+ while (timer_op* op = (num_cancelled != max_cancelled)
+ ? timer.op_queue_.front() : 0)
       {
         op->ec_ = boost::asio::error::operation_aborted;
         timer.op_queue_.pop();
         ops.push(op);
         ++num_cancelled;
       }
- remove_timer(timer);
+ if (timer.op_queue_.empty())
+ remove_timer(timer);
     }
     return num_cancelled;
   }
@@ -354,9 +357,10 @@
   // Dequeue all timers.
   BOOST_ASIO_DECL virtual void get_all_timers(op_queue<operation>& ops);
 
- // Cancel and dequeue the timers with the given token.
+ // Cancel and dequeue operations for the given timer.
   BOOST_ASIO_DECL std::size_t cancel_timer(
- per_timer_data& timer, op_queue<operation>& ops);
+ per_timer_data& timer, op_queue<operation>& ops,
+ std::size_t max_cancelled = (std::numeric_limits<std::size_t>::max)());
 
 private:
   timer_queue<forwarding_posix_time_traits> impl_;

Modified: trunk/boost/asio/detail/win_iocp_handle_read_op.hpp
==============================================================================
--- trunk/boost/asio/detail/win_iocp_handle_read_op.hpp (original)
+++ trunk/boost/asio/detail/win_iocp_handle_read_op.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -41,10 +41,11 @@
 public:
   BOOST_ASIO_DEFINE_HANDLER_PTR(win_iocp_handle_read_op);
 
- win_iocp_handle_read_op(const MutableBufferSequence& buffers, Handler handler)
+ win_iocp_handle_read_op(
+ const MutableBufferSequence& buffers, Handler& handler)
     : operation(&win_iocp_handle_read_op::do_complete),
       buffers_(buffers),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler))
   {
   }
 

Modified: trunk/boost/asio/detail/win_iocp_handle_service.hpp
==============================================================================
--- trunk/boost/asio/detail/win_iocp_handle_service.hpp (original)
+++ trunk/boost/asio/detail/win_iocp_handle_service.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -41,7 +41,7 @@
 {
 public:
   // The native type of a stream handle.
- typedef HANDLE native_type;
+ typedef HANDLE native_handle_type;
 
   // The implementation type of the stream handle.
   class implementation_type
@@ -61,7 +61,7 @@
     friend class win_iocp_handle_service;
 
     // The native stream handle representation.
- native_type handle_;
+ native_handle_type handle_;
 
     // The ID of the thread from which it is safe to cancel asynchronous
     // operations. 0 means no asynchronous operations have been started yet.
@@ -87,7 +87,7 @@
 
   // Assign a native handle to a handle implementation.
   BOOST_ASIO_DECL boost::system::error_code assign(implementation_type& impl,
- const native_type& native_handle, boost::system::error_code& ec);
+ const native_handle_type& handle, boost::system::error_code& ec);
 
   // Determine whether the handle is open.
   bool is_open(const implementation_type& impl) const
@@ -100,7 +100,7 @@
       boost::system::error_code& ec);
 
   // Get the native handle representation.
- native_type native(const implementation_type& impl) const
+ native_handle_type native_handle(const implementation_type& impl) const
   {
     return impl.handle_;
   }
@@ -134,7 +134,7 @@
   // lifetime of the asynchronous operation.
   template <typename ConstBufferSequence, typename Handler>
   void async_write_some(implementation_type& impl,
- const ConstBufferSequence& buffers, Handler handler)
+ const ConstBufferSequence& buffers, Handler& handler)
   {
     async_write_some_at(impl, 0, buffers, handler);
   }
@@ -143,7 +143,7 @@
   // must be valid for the lifetime of the asynchronous operation.
   template <typename ConstBufferSequence, typename Handler>
   void async_write_some_at(implementation_type& impl, boost::uint64_t offset,
- const ConstBufferSequence& buffers, Handler handler)
+ const ConstBufferSequence& buffers, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef win_iocp_handle_write_op<ConstBufferSequence, Handler> op;
@@ -182,7 +182,7 @@
   // valid for the lifetime of the asynchronous operation.
   template <typename MutableBufferSequence, typename Handler>
   void async_read_some(implementation_type& impl,
- const MutableBufferSequence& buffers, Handler handler)
+ const MutableBufferSequence& buffers, Handler& handler)
   {
     async_read_some_at(impl, 0, buffers, handler);
   }
@@ -192,7 +192,7 @@
   // operation.
   template <typename MutableBufferSequence, typename Handler>
   void async_read_some_at(implementation_type& impl, boost::uint64_t offset,
- const MutableBufferSequence& buffers, Handler handler)
+ const MutableBufferSequence& buffers, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef win_iocp_handle_read_op<MutableBufferSequence, Handler> op;

Modified: trunk/boost/asio/detail/win_iocp_handle_write_op.hpp
==============================================================================
--- trunk/boost/asio/detail/win_iocp_handle_write_op.hpp (original)
+++ trunk/boost/asio/detail/win_iocp_handle_write_op.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -41,10 +41,10 @@
 public:
   BOOST_ASIO_DEFINE_HANDLER_PTR(win_iocp_handle_write_op);
 
- win_iocp_handle_write_op(const ConstBufferSequence& buffers, Handler handler)
+ win_iocp_handle_write_op(const ConstBufferSequence& buffers, Handler& handler)
     : operation(&win_iocp_handle_write_op::do_complete),
       buffers_(buffers),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler))
   {
   }
 

Modified: trunk/boost/asio/detail/win_iocp_io_service.hpp
==============================================================================
--- trunk/boost/asio/detail/win_iocp_io_service.hpp (original)
+++ trunk/boost/asio/detail/win_iocp_io_service.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -19,6 +19,7 @@
 
 #if defined(BOOST_ASIO_HAS_IOCP)
 
+#include <boost/limits.hpp>
 #include <boost/scoped_ptr.hpp>
 #include <boost/asio/io_service.hpp>
 #include <boost/asio/detail/mutex.hpp>
@@ -76,6 +77,12 @@
   // Stop the event processing loop.
   BOOST_ASIO_DECL void stop();
 
+ // Determine whether the io_service is stopped.
+ bool stopped() const
+ {
+ return ::InterlockedExchangeAdd(&stopped_, 0) != 0;
+ }
+
   // Reset in preparation for a subsequent run invocation.
   void reset()
   {
@@ -97,11 +104,11 @@
 
   // Request invocation of the given handler.
   template <typename Handler>
- void dispatch(Handler handler);
+ void dispatch(Handler& handler);
 
   // Request invocation of the given handler and return immediately.
   template <typename Handler>
- void post(Handler handler);
+ void post(Handler& handler);
 
   // Request invocation of the given operation and return immediately. Assumes
   // that work_started() has not yet been called for the operation.
@@ -156,7 +163,8 @@
   // handlers that have been posted or dispatched.
   template <typename Time_Traits>
   std::size_t cancel_timer(timer_queue<Time_Traits>& queue,
- typename timer_queue<Time_Traits>::per_timer_data& timer);
+ typename timer_queue<Time_Traits>::per_timer_data& timer,
+ std::size_t max_cancelled = (std::numeric_limits<std::size_t>::max)());
 
 private:
 #if defined(WINVER) && (WINVER < 0x0500)
@@ -199,7 +207,7 @@
   long outstanding_work_;
 
   // Flag to indicate whether the event loop has been stopped.
- long stopped_;
+ mutable long stopped_;
 
   // Flag to indicate whether the service has been shut down.
   long shutdown_;

Modified: trunk/boost/asio/detail/win_iocp_null_buffers_op.hpp
==============================================================================
--- trunk/boost/asio/detail/win_iocp_null_buffers_op.hpp (original)
+++ trunk/boost/asio/detail/win_iocp_null_buffers_op.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -42,11 +42,11 @@
   BOOST_ASIO_DEFINE_HANDLER_PTR(win_iocp_null_buffers_op);
 
   win_iocp_null_buffers_op(socket_ops::weak_cancel_token_type cancel_token,
- Handler handler)
+ Handler& handler)
     : reactor_op(&win_iocp_null_buffers_op::do_perform,
         &win_iocp_null_buffers_op::do_complete),
       cancel_token_(cancel_token),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler))
   {
   }
 

Modified: trunk/boost/asio/detail/win_iocp_overlapped_op.hpp
==============================================================================
--- trunk/boost/asio/detail/win_iocp_overlapped_op.hpp (original)
+++ trunk/boost/asio/detail/win_iocp_overlapped_op.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -39,9 +39,9 @@
 public:
   BOOST_ASIO_DEFINE_HANDLER_PTR(win_iocp_overlapped_op);
 
- win_iocp_overlapped_op(Handler handler)
+ win_iocp_overlapped_op(Handler& handler)
     : operation(&win_iocp_overlapped_op::do_complete),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler))
   {
   }
 

Modified: trunk/boost/asio/detail/win_iocp_overlapped_ptr.hpp
==============================================================================
--- trunk/boost/asio/detail/win_iocp_overlapped_ptr.hpp (original)
+++ trunk/boost/asio/detail/win_iocp_overlapped_ptr.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -47,7 +47,7 @@
   // Construct an win_iocp_overlapped_ptr to contain the specified handler.
   template <typename Handler>
   explicit win_iocp_overlapped_ptr(
- boost::asio::io_service& io_service, Handler handler)
+ boost::asio::io_service& io_service, Handler& handler)
     : ptr_(0),
       iocp_service_(0)
   {
@@ -75,7 +75,7 @@
   // Reset to contain the specified handler, freeing any current OVERLAPPED
   // object.
   template <typename Handler>
- void reset(boost::asio::io_service& io_service, Handler handler)
+ void reset(boost::asio::io_service& io_service, Handler& handler)
   {
     typedef win_iocp_overlapped_op<Handler> op;
     typename op::ptr p = { boost::addressof(handler),

Modified: trunk/boost/asio/detail/win_iocp_serial_port_service.hpp
==============================================================================
--- trunk/boost/asio/detail/win_iocp_serial_port_service.hpp (original)
+++ trunk/boost/asio/detail/win_iocp_serial_port_service.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -36,7 +36,7 @@
 {
 public:
   // The native type of a serial port.
- typedef win_iocp_handle_service::native_type native_type;
+ typedef win_iocp_handle_service::native_handle_type native_handle_type;
 
   // The implementation type of the serial port.
   typedef win_iocp_handle_service::implementation_type implementation_type;
@@ -66,9 +66,9 @@
 
   // Assign a native handle to a serial port implementation.
   boost::system::error_code assign(implementation_type& impl,
- const native_type& native_handle, boost::system::error_code& ec)
+ const native_handle_type& handle, boost::system::error_code& ec)
   {
- return handle_service_.assign(impl, native_handle, ec);
+ return handle_service_.assign(impl, handle, ec);
   }
 
   // Determine whether the serial port is open.
@@ -85,9 +85,9 @@
   }
 
   // Get the native serial port representation.
- native_type native(implementation_type& impl)
+ native_handle_type native_handle(implementation_type& impl)
   {
- return handle_service_.native(impl);
+ return handle_service_.native_handle(impl);
   }
 
   // Cancel all operations associated with the handle.
@@ -137,7 +137,7 @@
   // lifetime of the asynchronous operation.
   template <typename ConstBufferSequence, typename Handler>
   void async_write_some(implementation_type& impl,
- const ConstBufferSequence& buffers, Handler handler)
+ const ConstBufferSequence& buffers, Handler& handler)
   {
     handle_service_.async_write_some(impl, buffers, handler);
   }
@@ -154,7 +154,7 @@
   // valid for the lifetime of the asynchronous operation.
   template <typename MutableBufferSequence, typename Handler>
   void async_read_some(implementation_type& impl,
- const MutableBufferSequence& buffers, Handler handler)
+ const MutableBufferSequence& buffers, Handler& handler)
   {
     handle_service_.async_read_some(impl, buffers, handler);
   }

Modified: trunk/boost/asio/detail/win_iocp_socket_accept_op.hpp
==============================================================================
--- trunk/boost/asio/detail/win_iocp_socket_accept_op.hpp (original)
+++ trunk/boost/asio/detail/win_iocp_socket_accept_op.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -45,7 +45,7 @@
   win_iocp_socket_accept_op(win_iocp_socket_service_base& socket_service,
       socket_type socket, Socket& peer, const Protocol& protocol,
       typename Protocol::endpoint* peer_endpoint,
- bool enable_connection_aborted, Handler handler)
+ bool enable_connection_aborted, Handler& handler)
     : operation(&win_iocp_socket_accept_op::do_complete),
       socket_service_(socket_service),
       socket_(socket),
@@ -53,7 +53,7 @@
       protocol_(protocol),
       peer_endpoint_(peer_endpoint),
       enable_connection_aborted_(enable_connection_aborted),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler))
   {
   }
 
@@ -107,7 +107,7 @@
       if (!ec)
       {
         o->peer_.assign(o->protocol_,
- typename Socket::native_type(
+ typename Socket::native_handle_type(
               o->new_socket_.get(), peer_endpoint), ec);
         if (!ec)
           o->new_socket_.release();

Modified: trunk/boost/asio/detail/win_iocp_socket_recv_op.hpp
==============================================================================
--- trunk/boost/asio/detail/win_iocp_socket_recv_op.hpp (original)
+++ trunk/boost/asio/detail/win_iocp_socket_recv_op.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -43,12 +43,12 @@
 
   win_iocp_socket_recv_op(socket_ops::state_type state,
       socket_ops::weak_cancel_token_type cancel_token,
- const MutableBufferSequence& buffers, Handler handler)
+ const MutableBufferSequence& buffers, Handler& handler)
     : operation(&win_iocp_socket_recv_op::do_complete),
       state_(state),
       cancel_token_(cancel_token),
       buffers_(buffers),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler))
   {
   }
 

Modified: trunk/boost/asio/detail/win_iocp_socket_recvfrom_op.hpp
==============================================================================
--- trunk/boost/asio/detail/win_iocp_socket_recvfrom_op.hpp (original)
+++ trunk/boost/asio/detail/win_iocp_socket_recvfrom_op.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -43,13 +43,13 @@
 
   win_iocp_socket_recvfrom_op(Endpoint& endpoint,
       socket_ops::weak_cancel_token_type cancel_token,
- const MutableBufferSequence& buffers, Handler handler)
+ const MutableBufferSequence& buffers, Handler& handler)
     : operation(&win_iocp_socket_recvfrom_op::do_complete),
       endpoint_(endpoint),
       endpoint_size_(static_cast<int>(endpoint.capacity())),
       cancel_token_(cancel_token),
       buffers_(buffers),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler))
   {
   }
 

Added: trunk/boost/asio/detail/win_iocp_socket_recvmsg_op.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/asio/detail/win_iocp_socket_recvmsg_op.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -0,0 +1,111 @@
+//
+// detail/win_iocp_socket_recvmsg_op.hpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// 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)
+//
+
+#ifndef BOOST_ASIO_DETAIL_WIN_IOCP_SOCKET_RECVMSG_OP_HPP
+#define BOOST_ASIO_DETAIL_WIN_IOCP_SOCKET_RECVMSG_OP_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
+
+#include <boost/asio/detail/config.hpp>
+
+#if defined(BOOST_ASIO_HAS_IOCP)
+
+#include <boost/utility/addressof.hpp>
+#include <boost/asio/detail/bind_handler.hpp>
+#include <boost/asio/detail/buffer_sequence_adapter.hpp>
+#include <boost/asio/detail/fenced_block.hpp>
+#include <boost/asio/detail/handler_alloc_helpers.hpp>
+#include <boost/asio/detail/handler_invoke_helpers.hpp>
+#include <boost/asio/detail/operation.hpp>
+#include <boost/asio/detail/socket_ops.hpp>
+#include <boost/asio/error.hpp>
+#include <boost/asio/socket_base.hpp>
+
+#include <boost/asio/detail/push_options.hpp>
+
+namespace boost {
+namespace asio {
+namespace detail {
+
+template <typename MutableBufferSequence, typename Handler>
+class win_iocp_socket_recvmsg_op : public operation
+{
+public:
+ BOOST_ASIO_DEFINE_HANDLER_PTR(win_iocp_socket_recvmsg_op);
+
+ win_iocp_socket_recvmsg_op(
+ socket_ops::weak_cancel_token_type cancel_token,
+ const MutableBufferSequence& buffers,
+ socket_base::message_flags& out_flags, Handler& handler)
+ : operation(&win_iocp_socket_recvmsg_op::do_complete),
+ cancel_token_(cancel_token),
+ buffers_(buffers),
+ out_flags_(out_flags),
+ handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler))
+ {
+ }
+
+ static void do_complete(io_service_impl* owner, operation* base,
+ boost::system::error_code ec, std::size_t bytes_transferred)
+ {
+ // Take ownership of the operation object.
+ win_iocp_socket_recvmsg_op* o(
+ static_cast<win_iocp_socket_recvmsg_op*>(base));
+ ptr p = { boost::addressof(o->handler_), o, o };
+
+#if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
+ // Check whether buffers are still valid.
+ if (owner)
+ {
+ buffer_sequence_adapter<boost::asio::mutable_buffer,
+ MutableBufferSequence>::validate(o->buffers_);
+ }
+#endif // defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
+
+ socket_ops::complete_iocp_recvmsg(o->cancel_token_, ec);
+ o->out_flags_ = 0;
+
+ // Make a copy of the handler so that the memory can be deallocated before
+ // the upcall is made. Even if we're not about to make an upcall, a
+ // sub-object of the handler may be the true owner of the memory associated
+ // with the handler. Consequently, a local copy of the handler is required
+ // to ensure that any owning sub-object remains valid until after we have
+ // deallocated the memory here.
+ detail::binder2<Handler, boost::system::error_code, std::size_t>
+ handler(o->handler_, ec, bytes_transferred);
+ p.h = boost::addressof(handler.handler_);
+ p.reset();
+
+ // Make the upcall if required.
+ if (owner)
+ {
+ boost::asio::detail::fenced_block b;
+ boost_asio_handler_invoke_helpers::invoke(handler, handler.handler_);
+ }
+ }
+
+private:
+ socket_ops::weak_cancel_token_type cancel_token_;
+ MutableBufferSequence buffers_;
+ socket_base::message_flags& out_flags_;
+ Handler handler_;
+};
+
+} // namespace detail
+} // namespace asio
+} // namespace boost
+
+#include <boost/asio/detail/pop_options.hpp>
+
+#endif // defined(BOOST_ASIO_HAS_IOCP)
+
+#endif // BOOST_ASIO_DETAIL_WIN_IOCP_SOCKET_RECVMSG_OP_HPP

Modified: trunk/boost/asio/detail/win_iocp_socket_send_op.hpp
==============================================================================
--- trunk/boost/asio/detail/win_iocp_socket_send_op.hpp (original)
+++ trunk/boost/asio/detail/win_iocp_socket_send_op.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -42,11 +42,11 @@
   BOOST_ASIO_DEFINE_HANDLER_PTR(win_iocp_socket_send_op);
 
   win_iocp_socket_send_op(socket_ops::weak_cancel_token_type cancel_token,
- const ConstBufferSequence& buffers, Handler handler)
+ const ConstBufferSequence& buffers, Handler& handler)
     : operation(&win_iocp_socket_send_op::do_complete),
       cancel_token_(cancel_token),
       buffers_(buffers),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler))
   {
   }
 

Modified: trunk/boost/asio/detail/win_iocp_socket_service.hpp
==============================================================================
--- trunk/boost/asio/detail/win_iocp_socket_service.hpp (original)
+++ trunk/boost/asio/detail/win_iocp_socket_service.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -61,16 +61,16 @@
   typedef typename Protocol::endpoint endpoint_type;
 
   // The native type of a socket.
- class native_type
+ class native_handle_type
   {
   public:
- native_type(socket_type s)
+ native_handle_type(socket_type s)
       : socket_(s),
         have_remote_endpoint_(false)
     {
     }
 
- native_type(socket_type s, const endpoint_type& ep)
+ native_handle_type(socket_type s, const endpoint_type& ep)
       : socket_(s),
         have_remote_endpoint_(true),
         remote_endpoint_(ep)
@@ -149,7 +149,7 @@
 
   // Assign a native socket to a socket implementation.
   boost::system::error_code assign(implementation_type& impl,
- const protocol_type& protocol, const native_type& native_socket,
+ const protocol_type& protocol, const native_handle_type& native_socket,
       boost::system::error_code& ec)
   {
     if (!do_assign(impl, protocol.type(), native_socket, ec))
@@ -162,11 +162,11 @@
   }
 
   // Get the native socket representation.
- native_type native(implementation_type& impl)
+ native_handle_type native_handle(implementation_type& impl)
   {
     if (impl.have_remote_endpoint_)
- return native_type(impl.socket_, impl.remote_endpoint_);
- return native_type(impl.socket_);
+ return native_handle_type(impl.socket_, impl.remote_endpoint_);
+ return native_handle_type(impl.socket_);
   }
 
   // Bind the socket to the specified local endpoint.
@@ -258,7 +258,7 @@
   template <typename ConstBufferSequence, typename Handler>
   void async_send_to(implementation_type& impl,
       const ConstBufferSequence& buffers, const endpoint_type& destination,
- socket_base::message_flags flags, Handler handler)
+ socket_base::message_flags flags, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef win_iocp_socket_send_op<ConstBufferSequence, Handler> op;
@@ -279,7 +279,7 @@
   // Start an asynchronous wait until data can be sent without blocking.
   template <typename Handler>
   void async_send_to(implementation_type& impl, const null_buffers&,
- const endpoint_type&, socket_base::message_flags, Handler handler)
+ const endpoint_type&, socket_base::message_flags, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef win_iocp_null_buffers_op<Handler> op;
@@ -334,7 +334,7 @@
   template <typename MutableBufferSequence, typename Handler>
   void async_receive_from(implementation_type& impl,
       const MutableBufferSequence& buffers, endpoint_type& sender_endp,
- socket_base::message_flags flags, Handler handler)
+ socket_base::message_flags flags, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef win_iocp_socket_recvfrom_op<
@@ -356,7 +356,7 @@
   template <typename Handler>
   void async_receive_from(implementation_type& impl,
       const null_buffers&, endpoint_type& sender_endpoint,
- socket_base::message_flags flags, Handler handler)
+ socket_base::message_flags flags, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef win_iocp_null_buffers_op<Handler> op;
@@ -405,7 +405,7 @@
   // must be valid until the accept's handler is invoked.
   template <typename Socket, typename Handler>
   void async_accept(implementation_type& impl, Socket& peer,
- endpoint_type* peer_endpoint, Handler handler)
+ endpoint_type* peer_endpoint, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef win_iocp_socket_accept_op<Socket, protocol_type, Handler> op;
@@ -436,7 +436,7 @@
   // Start an asynchronous connect.
   template <typename Handler>
   void async_connect(implementation_type& impl,
- const endpoint_type& peer_endpoint, Handler handler)
+ const endpoint_type& peer_endpoint, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef reactive_socket_connect_op<Handler> op;

Modified: trunk/boost/asio/detail/win_iocp_socket_service_base.hpp
==============================================================================
--- trunk/boost/asio/detail/win_iocp_socket_service_base.hpp (original)
+++ trunk/boost/asio/detail/win_iocp_socket_service_base.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -40,6 +40,7 @@
 #include <boost/asio/detail/win_iocp_null_buffers_op.hpp>
 #include <boost/asio/detail/win_iocp_socket_send_op.hpp>
 #include <boost/asio/detail/win_iocp_socket_recv_op.hpp>
+#include <boost/asio/detail/win_iocp_socket_recvmsg_op.hpp>
 
 #include <boost/asio/detail/push_options.hpp>
 
@@ -142,7 +143,35 @@
     return ec;
   }
 
- /// Disable sends or receives on the socket.
+ // Gets the non-blocking mode of the socket.
+ bool non_blocking(const base_implementation_type& impl) const
+ {
+ return (impl.state_ & socket_ops::user_set_non_blocking) != 0;
+ }
+
+ // Sets the non-blocking mode of the socket.
+ boost::system::error_code non_blocking(base_implementation_type& impl,
+ bool mode, boost::system::error_code& ec)
+ {
+ socket_ops::set_user_non_blocking(impl.socket_, impl.state_, mode, ec);
+ return ec;
+ }
+
+ // Gets the non-blocking mode of the native socket implementation.
+ bool native_non_blocking(const base_implementation_type& impl) const
+ {
+ return (impl.state_ & socket_ops::internal_non_blocking) != 0;
+ }
+
+ // Sets the non-blocking mode of the native socket implementation.
+ boost::system::error_code native_non_blocking(base_implementation_type& impl,
+ bool mode, boost::system::error_code& ec)
+ {
+ socket_ops::set_internal_non_blocking(impl.socket_, impl.state_, mode, ec);
+ return ec;
+ }
+
+ // Disable sends or receives on the socket.
   boost::system::error_code shutdown(base_implementation_type& impl,
       socket_base::shutdown_type what, boost::system::error_code& ec)
   {
@@ -178,7 +207,7 @@
   template <typename ConstBufferSequence, typename Handler>
   void async_send(base_implementation_type& impl,
       const ConstBufferSequence& buffers,
- socket_base::message_flags flags, Handler handler)
+ socket_base::message_flags flags, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef win_iocp_socket_send_op<ConstBufferSequence, Handler> op;
@@ -199,7 +228,7 @@
   // Start an asynchronous wait until data can be sent without blocking.
   template <typename Handler>
   void async_send(base_implementation_type& impl, const null_buffers&,
- socket_base::message_flags, Handler handler)
+ socket_base::message_flags, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef win_iocp_null_buffers_op<Handler> op;
@@ -240,7 +269,7 @@
   template <typename MutableBufferSequence, typename Handler>
   void async_receive(base_implementation_type& impl,
       const MutableBufferSequence& buffers,
- socket_base::message_flags flags, Handler handler)
+ socket_base::message_flags flags, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef win_iocp_socket_recv_op<MutableBufferSequence, Handler> op;
@@ -261,7 +290,7 @@
   // Wait until data can be received without blocking.
   template <typename Handler>
   void async_receive(base_implementation_type& impl, const null_buffers&,
- socket_base::message_flags flags, Handler handler)
+ socket_base::message_flags flags, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef win_iocp_null_buffers_op<Handler> op;
@@ -274,6 +303,77 @@
     p.v = p.p = 0;
   }
 
+ // Receive some data with associated flags. Returns the number of bytes
+ // received.
+ template <typename MutableBufferSequence>
+ size_t receive_with_flags(base_implementation_type& impl,
+ const MutableBufferSequence& buffers,
+ socket_base::message_flags in_flags,
+ socket_base::message_flags& out_flags, boost::system::error_code& ec)
+ {
+ buffer_sequence_adapter<boost::asio::mutable_buffer,
+ MutableBufferSequence> bufs(buffers);
+
+ return socket_ops::sync_recvmsg(impl.socket_, impl.state_,
+ bufs.buffers(), bufs.count(), in_flags, out_flags, ec);
+ }
+
+ // Wait until data can be received without blocking.
+ size_t receive_with_flags(base_implementation_type& impl,
+ const null_buffers&, socket_base::message_flags,
+ socket_base::message_flags& out_flags, boost::system::error_code& ec)
+ {
+ // Wait for socket to become ready.
+ socket_ops::poll_read(impl.socket_, ec);
+
+ // Clear out_flags, since we cannot give it any other sensible value when
+ // performing a null_buffers operation.
+ out_flags = 0;
+
+ return 0;
+ }
+
+ // Start an asynchronous receive. The buffer for the data being received
+ // must be valid for the lifetime of the asynchronous operation.
+ template <typename MutableBufferSequence, typename Handler>
+ void async_receive_with_flags(base_implementation_type& impl,
+ const MutableBufferSequence& buffers, socket_base::message_flags in_flags,
+ socket_base::message_flags& out_flags, Handler& handler)
+ {
+ // Allocate and construct an operation to wrap the handler.
+ typedef win_iocp_socket_recvmsg_op<MutableBufferSequence, Handler> op;
+ typename op::ptr p = { boost::addressof(handler),
+ boost_asio_handler_alloc_helpers::allocate(
+ sizeof(op), handler), 0 };
+ p.p = new (p.v) op(impl.cancel_token_, buffers, out_flags, handler);
+
+ buffer_sequence_adapter<boost::asio::mutable_buffer,
+ MutableBufferSequence> bufs(buffers);
+
+ start_receive_op(impl, bufs.buffers(), bufs.count(), in_flags, false, p.p);
+ p.v = p.p = 0;
+ }
+
+ // Wait until data can be received without blocking.
+ template <typename Handler>
+ void async_receive_with_flags(base_implementation_type& impl,
+ const null_buffers&, socket_base::message_flags in_flags,
+ socket_base::message_flags& out_flags, Handler& handler)
+ {
+ // Allocate and construct an operation to wrap the handler.
+ typedef win_iocp_null_buffers_op<Handler> op;
+ typename op::ptr p = { boost::addressof(handler),
+ boost_asio_handler_alloc_helpers::allocate(
+ sizeof(op), handler), 0 };
+ p.p = new (p.v) op(impl.cancel_token_, handler);
+
+ // Reset out_flags since it can be given no sensible value at this time.
+ out_flags = 0;
+
+ start_null_buffers_receive_op(impl, in_flags, p.p);
+ p.v = p.p = 0;
+ }
+
   // Helper function to restart an asynchronous accept operation.
   BOOST_ASIO_DECL void restart_accept_op(socket_type s,
       socket_holder& new_socket, int family, int type, int protocol,

Modified: trunk/boost/asio/detail/wince_thread.hpp
==============================================================================
--- trunk/boost/asio/detail/wince_thread.hpp (original)
+++ trunk/boost/asio/detail/wince_thread.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -39,7 +39,7 @@
 public:
   // Constructor.
   template <typename Function>
- wince_thread(Function f)
+ wince_thread(Function f, unsigned int = 0)
   {
     std::auto_ptr<func_base> arg(new func<Function>(f));
     DWORD thread_id = 0;

Modified: trunk/boost/asio/detail/wrapped_handler.hpp
==============================================================================
--- trunk/boost/asio/detail/wrapped_handler.hpp (original)
+++ trunk/boost/asio/detail/wrapped_handler.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -31,7 +31,7 @@
 public:
   typedef void result_type;
 
- wrapped_handler(Dispatcher dispatcher, Handler handler)
+ wrapped_handler(Dispatcher dispatcher, const Handler& handler)
     : dispatcher_(dispatcher),
       handler_(handler)
   {

Modified: trunk/boost/asio/error.hpp
==============================================================================
--- trunk/boost/asio/error.hpp (original)
+++ trunk/boost/asio/error.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -211,10 +211,6 @@
   fd_set_failure
 };
 
-enum ssl_errors
-{
-};
-
 inline const boost::system::error_category& get_system_category()
 {
   return boost::system::system_category();
@@ -245,9 +241,6 @@
 extern BOOST_ASIO_DECL
 const boost::system::error_category& get_misc_category();
 
-extern BOOST_ASIO_DECL
-const boost::system::error_category& get_ssl_category();
-
 static const boost::system::error_category& system_category
   = boost::asio::error::get_system_category();
 static const boost::system::error_category& netdb_category
@@ -256,12 +249,12 @@
   = boost::asio::error::get_addrinfo_category();
 static const boost::system::error_category& misc_category
   = boost::asio::error::get_misc_category();
-static const boost::system::error_category& ssl_category
- = boost::asio::error::get_ssl_category();
 
 } // namespace error
 } // namespace asio
+} // namespace boost
 
+namespace boost {
 namespace system {
 
 template<> struct is_error_code_enum<boost::asio::error::basic_errors>
@@ -284,13 +277,10 @@
   static const bool value = true;
 };
 
-template<> struct is_error_code_enum<boost::asio::error::ssl_errors>
-{
- static const bool value = true;
-};
-
 } // namespace system
+} // namespace boost
 
+namespace boost {
 namespace asio {
 namespace error {
 
@@ -318,12 +308,6 @@
       static_cast<int>(e), get_misc_category());
 }
 
-inline boost::system::error_code make_error_code(ssl_errors e)
-{
- return boost::system::error_code(
- static_cast<int>(e), get_ssl_category());
-}
-
 } // namespace error
 } // namespace asio
 } // namespace boost

Added: trunk/boost/asio/impl/connect.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/asio/impl/connect.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -0,0 +1,346 @@
+//
+// impl/connect.hpp
+// ~~~~~~~~~~~~~~~~
+//
+// 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)
+//
+
+#ifndef BOOST_ASIO_IMPL_CONNECT_HPP
+#define BOOST_ASIO_IMPL_CONNECT_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
+
+#include <boost/asio/detail/bind_handler.hpp>
+#include <boost/asio/detail/consuming_buffers.hpp>
+#include <boost/asio/detail/handler_alloc_helpers.hpp>
+#include <boost/asio/detail/handler_invoke_helpers.hpp>
+#include <boost/asio/detail/handler_type_requirements.hpp>
+#include <boost/asio/detail/throw_error.hpp>
+#include <boost/asio/error.hpp>
+
+#include <boost/asio/detail/push_options.hpp>
+
+namespace boost {
+namespace asio {
+
+namespace detail
+{
+ struct default_connect_condition
+ {
+ template <typename Iterator>
+ Iterator operator()(const boost::system::error_code&, Iterator next)
+ {
+ return next;
+ }
+ };
+}
+
+template <typename Protocol, typename SocketService, typename Iterator>
+Iterator connect(basic_socket<Protocol, SocketService>& s, Iterator begin)
+{
+ boost::system::error_code ec;
+ Iterator result = connect(s, begin, ec);
+ boost::asio::detail::throw_error(ec);
+ return result;
+}
+
+template <typename Protocol, typename SocketService, typename Iterator>
+inline Iterator connect(basic_socket<Protocol, SocketService>& s,
+ Iterator begin, boost::system::error_code& ec)
+{
+ return connect(s, begin, Iterator(), detail::default_connect_condition(), ec);
+}
+
+template <typename Protocol, typename SocketService, typename Iterator>
+Iterator connect(basic_socket<Protocol, SocketService>& s,
+ Iterator begin, Iterator end)
+{
+ boost::system::error_code ec;
+ Iterator result = connect(s, begin, end, ec);
+ boost::asio::detail::throw_error(ec);
+ return result;
+}
+
+template <typename Protocol, typename SocketService, typename Iterator>
+inline Iterator connect(basic_socket<Protocol, SocketService>& s,
+ Iterator begin, Iterator end, boost::system::error_code& ec)
+{
+ return connect(s, begin, end, detail::default_connect_condition(), ec);
+}
+
+template <typename Protocol, typename SocketService,
+ typename Iterator, typename ConnectCondition>
+Iterator connect(basic_socket<Protocol, SocketService>& s,
+ Iterator begin, ConnectCondition connect_condition)
+{
+ boost::system::error_code ec;
+ Iterator result = connect(s, begin, connect_condition, ec);
+ boost::asio::detail::throw_error(ec);
+ return result;
+}
+
+template <typename Protocol, typename SocketService,
+ typename Iterator, typename ConnectCondition>
+inline Iterator connect(basic_socket<Protocol, SocketService>& s,
+ Iterator begin, ConnectCondition connect_condition,
+ boost::system::error_code& ec)
+{
+ return connect(s, begin, Iterator(), connect_condition, ec);
+}
+
+template <typename Protocol, typename SocketService,
+ typename Iterator, typename ConnectCondition>
+Iterator connect(basic_socket<Protocol, SocketService>& s,
+ Iterator begin, Iterator end, ConnectCondition connect_condition)
+{
+ boost::system::error_code ec;
+ Iterator result = connect(s, begin, end, connect_condition, ec);
+ boost::asio::detail::throw_error(ec);
+ return result;
+}
+
+template <typename Protocol, typename SocketService,
+ typename Iterator, typename ConnectCondition>
+Iterator connect(basic_socket<Protocol, SocketService>& s,
+ Iterator begin, Iterator end, ConnectCondition connect_condition,
+ boost::system::error_code& ec)
+{
+ ec = boost::system::error_code();
+
+ for (Iterator iter = begin; iter != end; ++iter)
+ {
+ iter = connect_condition(ec, iter);
+ if (iter != end)
+ {
+ s.close(ec);
+ s.connect(*iter, ec);
+ if (!ec)
+ return iter;
+ }
+ }
+
+ if (!ec)
+ ec = boost::asio::error::not_found;
+
+ return end;
+}
+
+namespace detail
+{
+ // Enable the empty base class optimisation for the connect condition.
+ template <typename ConnectCondition>
+ class base_from_connect_condition
+ {
+ protected:
+ explicit base_from_connect_condition(
+ const ConnectCondition& connect_condition)
+ : connect_condition_(connect_condition)
+ {
+ }
+
+ template <typename Iterator>
+ void check_condition(const boost::system::error_code& ec,
+ Iterator& iter, Iterator& end)
+ {
+ if (iter != end)
+ iter = connect_condition_(ec, static_cast<const Iterator&>(iter));
+ }
+
+ private:
+ ConnectCondition connect_condition_;
+ };
+
+ // The default_connect_condition implementation is essentially a no-op. This
+ // template specialisation lets us eliminate all costs associated with it.
+ template <>
+ class base_from_connect_condition<default_connect_condition>
+ {
+ protected:
+ explicit base_from_connect_condition(const default_connect_condition&)
+ {
+ }
+
+ template <typename Iterator>
+ void check_condition(const boost::system::error_code&, Iterator&, Iterator&)
+ {
+ }
+ };
+
+ template <typename Protocol, typename SocketService, typename Iterator,
+ typename ConnectCondition, typename ComposedConnectHandler>
+ class connect_op : base_from_connect_condition<ConnectCondition>
+ {
+ public:
+ connect_op(basic_socket<Protocol, SocketService>& sock,
+ const Iterator& begin, const Iterator& end,
+ const ConnectCondition& connect_condition,
+ ComposedConnectHandler& handler)
+ : base_from_connect_condition<ConnectCondition>(connect_condition),
+ socket_(sock),
+ iter_(begin),
+ end_(end),
+ handler_(BOOST_ASIO_MOVE_CAST(ComposedConnectHandler)(handler))
+ {
+ }
+
+ void operator()(boost::system::error_code ec, int start = 0)
+ {
+ switch (start)
+ {
+ case 1:
+ for (;;)
+ {
+ this->check_condition(ec, iter_, end_);
+
+ if (iter_ != end_)
+ {
+ socket_.close(ec);
+ socket_.async_connect(*iter_, *this);
+ return;
+ }
+
+ if (start)
+ {
+ ec = boost::asio::error::not_found;
+ socket_.get_io_service().post(detail::bind_handler(*this, ec));
+ return;
+ }
+
+ default:
+
+ if (iter_ == end_)
+ break;
+
+ if (!socket_.is_open())
+ {
+ ec = boost::asio::error::operation_aborted;
+ break;
+ }
+
+ if (!ec)
+ break;
+
+ ++iter_;
+ }
+
+ handler_(static_cast<const boost::system::error_code&>(ec),
+ static_cast<const Iterator&>(iter_));
+ }
+ }
+
+ //private:
+ basic_socket<Protocol, SocketService>& socket_;
+ Iterator iter_;
+ Iterator end_;
+ ComposedConnectHandler handler_;
+ };
+
+ template <typename Protocol, typename SocketService, typename Iterator,
+ typename ConnectCondition, typename ComposedConnectHandler>
+ inline void* asio_handler_allocate(std::size_t size,
+ connect_op<Protocol, SocketService, Iterator,
+ ConnectCondition, ComposedConnectHandler>* this_handler)
+ {
+ return boost_asio_handler_alloc_helpers::allocate(
+ size, this_handler->handler_);
+ }
+
+ template <typename Protocol, typename SocketService, typename Iterator,
+ typename ConnectCondition, typename ComposedConnectHandler>
+ inline void asio_handler_deallocate(void* pointer, std::size_t size,
+ connect_op<Protocol, SocketService, Iterator,
+ ConnectCondition, ComposedConnectHandler>* this_handler)
+ {
+ boost_asio_handler_alloc_helpers::deallocate(
+ pointer, size, this_handler->handler_);
+ }
+
+ template <typename Function, typename Protocol,
+ typename SocketService, typename Iterator,
+ typename ConnectCondition, typename ComposedConnectHandler>
+ inline void asio_handler_invoke(const Function& function,
+ connect_op<Protocol, SocketService, Iterator,
+ ConnectCondition, ComposedConnectHandler>* this_handler)
+ {
+ boost_asio_handler_invoke_helpers::invoke(
+ function, this_handler->handler_);
+ }
+} // namespace detail
+
+template <typename Protocol, typename SocketService,
+ typename Iterator, typename ComposedConnectHandler>
+inline void async_connect(basic_socket<Protocol, SocketService>& s,
+ Iterator begin, ComposedConnectHandler handler)
+{
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ComposedConnectHandler.
+ BOOST_ASIO_COMPOSED_CONNECT_HANDLER_CHECK(
+ ComposedConnectHandler, handler, Iterator) type_check;
+
+ detail::connect_op<Protocol, SocketService, Iterator,
+ detail::default_connect_condition, ComposedConnectHandler>(
+ s, begin, Iterator(), detail::default_connect_condition(), handler)(
+ boost::system::error_code(), 1);
+}
+
+template <typename Protocol, typename SocketService,
+ typename Iterator, typename ComposedConnectHandler>
+inline void async_connect(basic_socket<Protocol, SocketService>& s,
+ Iterator begin, Iterator end, ComposedConnectHandler handler)
+{
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ComposedConnectHandler.
+ BOOST_ASIO_COMPOSED_CONNECT_HANDLER_CHECK(
+ ComposedConnectHandler, handler, Iterator) type_check;
+
+ detail::connect_op<Protocol, SocketService, Iterator,
+ detail::default_connect_condition, ComposedConnectHandler>(
+ s, begin, end, detail::default_connect_condition(), handler)(
+ boost::system::error_code(), 1);
+}
+
+template <typename Protocol, typename SocketService, typename Iterator,
+ typename ConnectCondition, typename ComposedConnectHandler>
+inline void async_connect(basic_socket<Protocol, SocketService>& s,
+ Iterator begin, ConnectCondition connect_condition,
+ ComposedConnectHandler handler)
+{
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ComposedConnectHandler.
+ BOOST_ASIO_COMPOSED_CONNECT_HANDLER_CHECK(
+ ComposedConnectHandler, handler, Iterator) type_check;
+
+ detail::connect_op<Protocol, SocketService, Iterator,
+ ConnectCondition, ComposedConnectHandler>(
+ s, begin, Iterator(), connect_condition, handler)(
+ boost::system::error_code(), 1);
+}
+
+template <typename Protocol, typename SocketService, typename Iterator,
+ typename ConnectCondition, typename ComposedConnectHandler>
+void async_connect(basic_socket<Protocol, SocketService>& s,
+ Iterator begin, Iterator end, ConnectCondition connect_condition,
+ ComposedConnectHandler handler)
+{
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ComposedConnectHandler.
+ BOOST_ASIO_COMPOSED_CONNECT_HANDLER_CHECK(
+ ComposedConnectHandler, handler, Iterator) type_check;
+
+ detail::connect_op<Protocol, SocketService, Iterator,
+ ConnectCondition, ComposedConnectHandler>(
+ s, begin, end, connect_condition, handler)(
+ boost::system::error_code(), 1);
+}
+
+} // namespace asio
+} // namespace boost
+
+#include <boost/asio/detail/pop_options.hpp>
+
+#endif // BOOST_ASIO_IMPL_CONNECT_HPP

Modified: trunk/boost/asio/impl/error.ipp
==============================================================================
--- trunk/boost/asio/impl/error.ipp (original)
+++ trunk/boost/asio/impl/error.ipp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -16,8 +16,6 @@
 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
 
 #include <boost/asio/detail/config.hpp>
-#include <boost/cerrno.hpp>
-#include <boost/system/error_code.hpp>
 #include <boost/asio/error.hpp>
 
 #include <boost/asio/detail/push_options.hpp>
@@ -122,30 +120,6 @@
   return instance;
 }
 
-namespace detail {
-
-class ssl_category : public boost::system::error_category
-{
-public:
- const char* name() const
- {
- return "asio.ssl";
- }
-
- std::string message(int) const
- {
- return "asio.ssl error";
- }
-};
-
-} // namespace detail
-
-const boost::system::error_category& get_ssl_category()
-{
- static detail::ssl_category instance;
- return instance;
-}
-
 } // namespace error
 } // namespace asio
 } // namespace boost

Modified: trunk/boost/asio/impl/io_service.hpp
==============================================================================
--- trunk/boost/asio/impl/io_service.hpp (original)
+++ trunk/boost/asio/impl/io_service.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -15,6 +15,7 @@
 # pragma once
 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
 
+#include <boost/asio/detail/handler_type_requirements.hpp>
 #include <boost/asio/detail/service_registry.hpp>
 
 #include <boost/asio/detail/push_options.hpp>
@@ -68,15 +69,23 @@
 namespace boost {
 namespace asio {
 
-template <typename Handler>
-inline void io_service::dispatch(Handler handler)
+template <typename CompletionHandler>
+inline void io_service::dispatch(CompletionHandler handler)
 {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a CompletionHandler.
+ BOOST_ASIO_COMPLETION_HANDLER_CHECK(CompletionHandler, handler) type_check;
+
   impl_.dispatch(handler);
 }
 
-template <typename Handler>
-inline void io_service::post(Handler handler)
+template <typename CompletionHandler>
+inline void io_service::post(CompletionHandler handler)
 {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a CompletionHandler.
+ BOOST_ASIO_COMPLETION_HANDLER_CHECK(CompletionHandler, handler) type_check;
+
   impl_.post(handler);
 }
 
@@ -108,21 +117,11 @@
   io_service_.impl_.work_finished();
 }
 
-inline boost::asio::io_service& io_service::work::io_service()
-{
- return io_service_;
-}
-
 inline boost::asio::io_service& io_service::work::get_io_service()
 {
   return io_service_;
 }
 
-inline boost::asio::io_service& io_service::service::io_service()
-{
- return owner_;
-}
-
 inline boost::asio::io_service& io_service::service::get_io_service()
 {
   return owner_;

Modified: trunk/boost/asio/impl/io_service.ipp
==============================================================================
--- trunk/boost/asio/impl/io_service.ipp (original)
+++ trunk/boost/asio/impl/io_service.ipp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -108,6 +108,11 @@
   impl_.stop();
 }
 
+bool io_service::stopped() const
+{
+ return impl_.stopped();
+}
+
 void io_service::reset()
 {
   impl_.reset();

Modified: trunk/boost/asio/impl/read.hpp
==============================================================================
--- trunk/boost/asio/impl/read.hpp (original)
+++ trunk/boost/asio/impl/read.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -23,6 +23,7 @@
 #include <boost/asio/detail/consuming_buffers.hpp>
 #include <boost/asio/detail/handler_alloc_helpers.hpp>
 #include <boost/asio/detail/handler_invoke_helpers.hpp>
+#include <boost/asio/detail/handler_type_requirements.hpp>
 #include <boost/asio/detail/throw_error.hpp>
 #include <boost/asio/error.hpp>
 
@@ -62,6 +63,13 @@
   return bytes_transferred;
 }
 
+template <typename SyncReadStream, typename MutableBufferSequence>
+inline std::size_t read(SyncReadStream& s, const MutableBufferSequence& buffers,
+ boost::system::error_code& ec)
+{
+ return read(s, buffers, transfer_all(), ec);
+}
+
 template <typename SyncReadStream, typename MutableBufferSequence,
     typename CompletionCondition>
 inline std::size_t read(SyncReadStream& s, const MutableBufferSequence& buffers,
@@ -108,6 +116,14 @@
   return bytes_transferred;
 }
 
+template <typename SyncReadStream, typename Allocator>
+inline std::size_t read(SyncReadStream& s,
+ boost::asio::basic_streambuf<Allocator>& b,
+ boost::system::error_code& ec)
+{
+ return read(s, b, transfer_all(), ec);
+}
+
 template <typename SyncReadStream, typename Allocator,
     typename CompletionCondition>
 inline std::size_t read(SyncReadStream& s,
@@ -131,13 +147,13 @@
   {
   public:
     read_op(AsyncReadStream& stream, const MutableBufferSequence& buffers,
- CompletionCondition completion_condition, ReadHandler handler)
+ CompletionCondition completion_condition, ReadHandler& handler)
       : detail::base_from_completion_cond<
           CompletionCondition>(completion_condition),
         stream_(stream),
         buffers_(buffers),
         total_transferred_(0),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))
     {
     }
 
@@ -182,13 +198,13 @@
     read_op(AsyncReadStream& stream,
         const boost::asio::mutable_buffers_1& buffers,
         CompletionCondition completion_condition,
- ReadHandler handler)
+ ReadHandler& handler)
       : detail::base_from_completion_cond<
           CompletionCondition>(completion_condition),
         stream_(stream),
         buffer_(buffers),
         total_transferred_(0),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))
     {
     }
 
@@ -260,6 +276,10 @@
 inline void async_read(AsyncReadStream& s, const MutableBufferSequence& buffers,
     CompletionCondition completion_condition, ReadHandler handler)
 {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
   detail::read_op<AsyncReadStream, MutableBufferSequence,
     CompletionCondition, ReadHandler>(
       s, buffers, completion_condition, handler)(
@@ -271,7 +291,14 @@
 inline void async_read(AsyncReadStream& s, const MutableBufferSequence& buffers,
     ReadHandler handler)
 {
- async_read(s, buffers, transfer_all(), handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
+ detail::read_op<AsyncReadStream, MutableBufferSequence,
+ detail::transfer_all_t, ReadHandler>(
+ s, buffers, transfer_all(), handler)(
+ boost::system::error_code(), 0, 1);
 }
 
 #if !defined(BOOST_NO_IOSTREAM)
@@ -286,13 +313,13 @@
   public:
     read_streambuf_op(AsyncReadStream& stream,
         basic_streambuf<Allocator>& streambuf,
- CompletionCondition completion_condition, ReadHandler handler)
+ CompletionCondition completion_condition, ReadHandler& handler)
       : detail::base_from_completion_cond<
           CompletionCondition>(completion_condition),
         stream_(stream),
         streambuf_(streambuf),
         total_transferred_(0),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))
     {
     }
 
@@ -365,6 +392,10 @@
     boost::asio::basic_streambuf<Allocator>& b,
     CompletionCondition completion_condition, ReadHandler handler)
 {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
   detail::read_streambuf_op<AsyncReadStream,
     Allocator, CompletionCondition, ReadHandler>(
       s, b, completion_condition, handler)(
@@ -375,7 +406,14 @@
 inline void async_read(AsyncReadStream& s,
     boost::asio::basic_streambuf<Allocator>& b, ReadHandler handler)
 {
- async_read(s, b, transfer_all(), handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
+ detail::read_streambuf_op<AsyncReadStream,
+ Allocator, detail::transfer_all_t, ReadHandler>(
+ s, b, transfer_all(), handler)(
+ boost::system::error_code(), 0, 1);
 }
 
 #endif // !defined(BOOST_NO_IOSTREAM)

Modified: trunk/boost/asio/impl/read_at.hpp
==============================================================================
--- trunk/boost/asio/impl/read_at.hpp (original)
+++ trunk/boost/asio/impl/read_at.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -23,6 +23,7 @@
 #include <boost/asio/detail/consuming_buffers.hpp>
 #include <boost/asio/detail/handler_alloc_helpers.hpp>
 #include <boost/asio/detail/handler_invoke_helpers.hpp>
+#include <boost/asio/detail/handler_type_requirements.hpp>
 #include <boost/asio/detail/throw_error.hpp>
 #include <boost/asio/error.hpp>
 
@@ -66,6 +67,14 @@
   return bytes_transferred;
 }
 
+template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence>
+inline std::size_t read_at(SyncRandomAccessReadDevice& d,
+ boost::uint64_t offset, const MutableBufferSequence& buffers,
+ boost::system::error_code& ec)
+{
+ return read_at(d, offset, buffers, transfer_all(), ec);
+}
+
 template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence,
     typename CompletionCondition>
 inline std::size_t read_at(SyncRandomAccessReadDevice& d,
@@ -116,6 +125,14 @@
   return bytes_transferred;
 }
 
+template <typename SyncRandomAccessReadDevice, typename Allocator>
+inline std::size_t read_at(SyncRandomAccessReadDevice& d,
+ boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b,
+ boost::system::error_code& ec)
+{
+ return read_at(d, offset, b, transfer_all(), ec);
+}
+
 template <typename SyncRandomAccessReadDevice, typename Allocator,
     typename CompletionCondition>
 inline std::size_t read_at(SyncRandomAccessReadDevice& d,
@@ -142,14 +159,14 @@
   public:
     read_at_op(AsyncRandomAccessReadDevice& device,
         boost::uint64_t offset, const MutableBufferSequence& buffers,
- CompletionCondition completion_condition, ReadHandler handler)
+ CompletionCondition completion_condition, ReadHandler& handler)
       : detail::base_from_completion_cond<
           CompletionCondition>(completion_condition),
         device_(device),
         offset_(offset),
         buffers_(buffers),
         total_transferred_(0),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))
     {
     }
 
@@ -195,14 +212,14 @@
   public:
     read_at_op(AsyncRandomAccessReadDevice& device,
         boost::uint64_t offset, const boost::asio::mutable_buffers_1& buffers,
- CompletionCondition completion_condition, ReadHandler handler)
+ CompletionCondition completion_condition, ReadHandler& handler)
       : detail::base_from_completion_cond<
           CompletionCondition>(completion_condition),
         device_(device),
         offset_(offset),
         buffer_(buffers),
         total_transferred_(0),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))
     {
     }
 
@@ -278,6 +295,10 @@
     boost::uint64_t offset, const MutableBufferSequence& buffers,
     CompletionCondition completion_condition, ReadHandler handler)
 {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
   detail::read_at_op<AsyncRandomAccessReadDevice,
     MutableBufferSequence, CompletionCondition, ReadHandler>(
       d, offset, buffers, completion_condition, handler)(
@@ -290,7 +311,14 @@
     boost::uint64_t offset, const MutableBufferSequence& buffers,
     ReadHandler handler)
 {
- async_read_at(d, offset, buffers, transfer_all(), handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
+ detail::read_at_op<AsyncRandomAccessReadDevice,
+ MutableBufferSequence, detail::transfer_all_t, ReadHandler>(
+ d, offset, buffers, transfer_all(), handler)(
+ boost::system::error_code(), 0, 1);
 }
 
 #if !defined(BOOST_NO_IOSTREAM)
@@ -305,14 +333,14 @@
   public:
     read_at_streambuf_op(AsyncRandomAccessReadDevice& device,
         boost::uint64_t offset, basic_streambuf<Allocator>& streambuf,
- CompletionCondition completion_condition, ReadHandler handler)
+ CompletionCondition completion_condition, ReadHandler& handler)
       : detail::base_from_completion_cond<
           CompletionCondition>(completion_condition),
         device_(device),
         offset_(offset),
         streambuf_(streambuf),
         total_transferred_(0),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))
     {
     }
 
@@ -387,6 +415,10 @@
     boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b,
     CompletionCondition completion_condition, ReadHandler handler)
 {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
   detail::read_at_streambuf_op<AsyncRandomAccessReadDevice,
     Allocator, CompletionCondition, ReadHandler>(
       d, offset, b, completion_condition, handler)(
@@ -399,7 +431,14 @@
     boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b,
     ReadHandler handler)
 {
- async_read_at(d, offset, b, transfer_all(), handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
+ detail::read_at_streambuf_op<AsyncRandomAccessReadDevice,
+ Allocator, detail::transfer_all_t, ReadHandler>(
+ d, offset, b, transfer_all(), handler)(
+ boost::system::error_code(), 0, 1);
 }
 
 #endif // !defined(BOOST_NO_IOSTREAM)

Modified: trunk/boost/asio/impl/read_until.hpp
==============================================================================
--- trunk/boost/asio/impl/read_until.hpp (original)
+++ trunk/boost/asio/impl/read_until.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -25,6 +25,7 @@
 #include <boost/asio/detail/bind_handler.hpp>
 #include <boost/asio/detail/handler_alloc_helpers.hpp>
 #include <boost/asio/detail/handler_invoke_helpers.hpp>
+#include <boost/asio/detail/handler_type_requirements.hpp>
 #include <boost/asio/detail/throw_error.hpp>
 
 #include <boost/asio/detail/push_options.hpp>
@@ -56,11 +57,11 @@
     typedef boost::asio::buffers_iterator<const_buffers_type> iterator;
     const_buffers_type buffers = b.data();
     iterator begin = iterator::begin(buffers);
- iterator start = begin + search_position;
+ iterator start_pos = begin + search_position;
     iterator end = iterator::end(buffers);
 
     // Look for a match.
- iterator iter = std::find(start, end, delim);
+ iterator iter = std::find(start_pos, end, delim);
     if (iter != end)
     {
       // Found a match. We're done.
@@ -147,12 +148,12 @@
     typedef boost::asio::buffers_iterator<const_buffers_type> iterator;
     const_buffers_type buffers = b.data();
     iterator begin = iterator::begin(buffers);
- iterator start = begin + search_position;
+ iterator start_pos = begin + search_position;
     iterator end = iterator::end(buffers);
 
     // Look for a match.
     std::pair<iterator, bool> result = detail::partial_search(
- start, end, delim.begin(), delim.end());
+ start_pos, end, delim.begin(), delim.end());
     if (result.first != end)
     {
       if (result.second)
@@ -212,14 +213,14 @@
     typedef boost::asio::buffers_iterator<const_buffers_type> iterator;
     const_buffers_type buffers = b.data();
     iterator begin = iterator::begin(buffers);
- iterator start = begin + search_position;
+ iterator start_pos = begin + search_position;
     iterator end = iterator::end(buffers);
 
     // Look for a match.
     boost::match_results<iterator,
       typename std::vector<boost::sub_match<iterator> >::allocator_type>
         match_results;
- if (regex_search(start, end, match_results, expr,
+ if (regex_search(start_pos, end, match_results, expr,
           boost::match_default | boost::match_partial))
     {
       if (match_results[0].matched)
@@ -270,11 +271,11 @@
     typedef boost::asio::buffers_iterator<const_buffers_type> iterator;
     const_buffers_type buffers = b.data();
     iterator begin = iterator::begin(buffers);
- iterator start = begin + search_position;
+ iterator start_pos = begin + search_position;
     iterator end = iterator::end(buffers);
 
     // Look for a match.
- std::pair<iterator, bool> result = match_condition(start, end);
+ std::pair<iterator, bool> result = match_condition(start_pos, end);
     if (result.second)
     {
       // Full match. We're done.
@@ -326,12 +327,12 @@
   public:
     read_until_delim_op(AsyncReadStream& stream,
         boost::asio::basic_streambuf<Allocator>& streambuf,
- char delim, ReadHandler handler)
+ char delim, ReadHandler& handler)
       : stream_(stream),
         streambuf_(streambuf),
         delim_(delim),
         search_position_(0),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))
     {
     }
 
@@ -352,11 +353,11 @@
             typedef boost::asio::buffers_iterator<const_buffers_type> iterator;
             const_buffers_type buffers = streambuf_.data();
             iterator begin = iterator::begin(buffers);
- iterator start = begin + search_position_;
+ iterator start_pos = begin + search_position_;
             iterator end = iterator::end(buffers);
 
             // Look for a match.
- iterator iter = std::find(start, end, delim_);
+ iterator iter = std::find(start_pos, end, delim_);
             if (iter != end)
             {
               // Found a match. We're done.
@@ -445,6 +446,10 @@
 void async_read_until(AsyncReadStream& s,
     boost::asio::basic_streambuf<Allocator>& b, char delim, ReadHandler handler)
 {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
   detail::read_until_delim_op<
     AsyncReadStream, Allocator, ReadHandler>(
       s, b, delim, handler)(
@@ -459,12 +464,12 @@
   public:
     read_until_delim_string_op(AsyncReadStream& stream,
         boost::asio::basic_streambuf<Allocator>& streambuf,
- const std::string& delim, ReadHandler handler)
+ const std::string& delim, ReadHandler& handler)
       : stream_(stream),
         streambuf_(streambuf),
         delim_(delim),
         search_position_(0),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))
     {
     }
 
@@ -485,12 +490,12 @@
             typedef boost::asio::buffers_iterator<const_buffers_type> iterator;
             const_buffers_type buffers = streambuf_.data();
             iterator begin = iterator::begin(buffers);
- iterator start = begin + search_position_;
+ iterator start_pos = begin + search_position_;
             iterator end = iterator::end(buffers);
 
             // Look for a match.
             std::pair<iterator, bool> result = detail::partial_search(
- start, end, delim_.begin(), delim_.end());
+ start_pos, end, delim_.begin(), delim_.end());
             if (result.first != end && result.second)
             {
               // Full match. We're done.
@@ -590,6 +595,10 @@
     boost::asio::basic_streambuf<Allocator>& b, const std::string& delim,
     ReadHandler handler)
 {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
   detail::read_until_delim_string_op<
     AsyncReadStream, Allocator, ReadHandler>(
       s, b, delim, handler)(
@@ -605,12 +614,12 @@
   public:
     read_until_expr_op(AsyncReadStream& stream,
         boost::asio::basic_streambuf<Allocator>& streambuf,
- const boost::regex& expr, ReadHandler handler)
+ const boost::regex& expr, ReadHandler& handler)
       : stream_(stream),
         streambuf_(streambuf),
         expr_(expr),
         search_position_(0),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))
     {
     }
 
@@ -631,14 +640,14 @@
             typedef boost::asio::buffers_iterator<const_buffers_type> iterator;
             const_buffers_type buffers = streambuf_.data();
             iterator begin = iterator::begin(buffers);
- iterator start = begin + search_position_;
+ iterator start_pos = begin + search_position_;
             iterator end = iterator::end(buffers);
 
             // Look for a match.
             boost::match_results<iterator,
               typename std::vector<boost::sub_match<iterator> >::allocator_type>
                 match_results;
- bool match = regex_search(start, end, match_results, expr_,
+ bool match = regex_search(start_pos, end, match_results, expr_,
                 boost::match_default | boost::match_partial);
             if (match && match_results[0].matched)
             {
@@ -741,6 +750,10 @@
     boost::asio::basic_streambuf<Allocator>& b, const boost::regex& expr,
     ReadHandler handler)
 {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
   detail::read_until_expr_op<AsyncReadStream,
     Allocator, boost::regex, ReadHandler>(
       s, b, expr, handler)(
@@ -756,12 +769,12 @@
   public:
     read_until_match_op(AsyncReadStream& stream,
         boost::asio::basic_streambuf<Allocator>& streambuf,
- MatchCondition match_condition, ReadHandler handler)
+ MatchCondition match_condition, ReadHandler& handler)
       : stream_(stream),
         streambuf_(streambuf),
         match_condition_(match_condition),
         search_position_(0),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))
     {
     }
 
@@ -782,11 +795,11 @@
             typedef boost::asio::buffers_iterator<const_buffers_type> iterator;
             const_buffers_type buffers = streambuf_.data();
             iterator begin = iterator::begin(buffers);
- iterator start = begin + search_position_;
+ iterator start_pos = begin + search_position_;
             iterator end = iterator::end(buffers);
 
             // Look for a match.
- std::pair<iterator, bool> result = match_condition_(start, end);
+ std::pair<iterator, bool> result = match_condition_(start_pos, end);
             if (result.second)
             {
               // Full match. We're done.
@@ -890,6 +903,10 @@
     MatchCondition match_condition, ReadHandler handler,
     typename boost::enable_if<is_match_condition<MatchCondition> >::type*)
 {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
   detail::read_until_match_op<
     AsyncReadStream, Allocator, MatchCondition, ReadHandler>(
       s, b, match_condition, handler)(

Modified: trunk/boost/asio/impl/write.hpp
==============================================================================
--- trunk/boost/asio/impl/write.hpp (original)
+++ trunk/boost/asio/impl/write.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -22,6 +22,7 @@
 #include <boost/asio/detail/consuming_buffers.hpp>
 #include <boost/asio/detail/handler_alloc_helpers.hpp>
 #include <boost/asio/detail/handler_invoke_helpers.hpp>
+#include <boost/asio/detail/handler_type_requirements.hpp>
 #include <boost/asio/detail/throw_error.hpp>
 
 #include <boost/asio/detail/push_options.hpp>
@@ -60,6 +61,13 @@
   return bytes_transferred;
 }
 
+template <typename SyncWriteStream, typename ConstBufferSequence>
+inline std::size_t write(SyncWriteStream& s, const ConstBufferSequence& buffers,
+ boost::system::error_code& ec)
+{
+ return write(s, buffers, transfer_all(), ec);
+}
+
 template <typename SyncWriteStream, typename ConstBufferSequence,
     typename CompletionCondition>
 inline std::size_t write(SyncWriteStream& s, const ConstBufferSequence& buffers,
@@ -94,6 +102,14 @@
   return bytes_transferred;
 }
 
+template <typename SyncWriteStream, typename Allocator>
+inline std::size_t write(SyncWriteStream& s,
+ boost::asio::basic_streambuf<Allocator>& b,
+ boost::system::error_code& ec)
+{
+ return write(s, b, transfer_all(), ec);
+}
+
 template <typename SyncWriteStream, typename Allocator,
     typename CompletionCondition>
 inline std::size_t write(SyncWriteStream& s,
@@ -117,13 +133,13 @@
   {
   public:
     write_op(AsyncWriteStream& stream, const ConstBufferSequence& buffers,
- CompletionCondition completion_condition, WriteHandler handler)
+ CompletionCondition completion_condition, WriteHandler& handler)
       : detail::base_from_completion_cond<
           CompletionCondition>(completion_condition),
         stream_(stream),
         buffers_(buffers),
         total_transferred_(0),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))
     {
     }
 
@@ -168,13 +184,13 @@
     write_op(AsyncWriteStream& stream,
         const boost::asio::mutable_buffers_1& buffers,
         CompletionCondition completion_condition,
- WriteHandler handler)
+ WriteHandler& handler)
       : detail::base_from_completion_cond<
           CompletionCondition>(completion_condition),
         stream_(stream),
         buffer_(buffers),
         total_transferred_(0),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))
     {
     }
 
@@ -219,13 +235,13 @@
     write_op(AsyncWriteStream& stream,
         const boost::asio::const_buffers_1& buffers,
         CompletionCondition completion_condition,
- WriteHandler handler)
+ WriteHandler& handler)
       : detail::base_from_completion_cond<
           CompletionCondition>(completion_condition),
         stream_(stream),
         buffer_(buffers),
         total_transferred_(0),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))
     {
     }
 
@@ -297,6 +313,10 @@
 inline void async_write(AsyncWriteStream& s, const ConstBufferSequence& buffers,
     CompletionCondition completion_condition, WriteHandler handler)
 {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a WriteHandler.
+ BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
+
   detail::write_op<AsyncWriteStream, ConstBufferSequence,
     CompletionCondition, WriteHandler>(
       s, buffers, completion_condition, handler)(
@@ -308,7 +328,14 @@
 inline void async_write(AsyncWriteStream& s, const ConstBufferSequence& buffers,
     WriteHandler handler)
 {
- async_write(s, buffers, transfer_all(), handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a WriteHandler.
+ BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
+
+ detail::write_op<AsyncWriteStream, ConstBufferSequence,
+ detail::transfer_all_t, WriteHandler>(
+ s, buffers, transfer_all(), handler)(
+ boost::system::error_code(), 0, 1);
 }
 
 #if !defined(BOOST_NO_IOSTREAM)
@@ -321,9 +348,9 @@
   {
   public:
     write_streambuf_handler(boost::asio::basic_streambuf<Allocator>& streambuf,
- WriteHandler handler)
+ WriteHandler& handler)
       : streambuf_(streambuf),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))
     {
     }
 
@@ -376,6 +403,10 @@
     boost::asio::basic_streambuf<Allocator>& b,
     CompletionCondition completion_condition, WriteHandler handler)
 {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a WriteHandler.
+ BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
+
   async_write(s, b.data(), completion_condition,
       detail::write_streambuf_handler<
         AsyncWriteStream, Allocator, WriteHandler>(b, handler));
@@ -385,7 +416,13 @@
 inline void async_write(AsyncWriteStream& s,
     boost::asio::basic_streambuf<Allocator>& b, WriteHandler handler)
 {
- async_write(s, b, transfer_all(), handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a WriteHandler.
+ BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
+
+ async_write(s, b.data(), transfer_all(),
+ detail::write_streambuf_handler<
+ AsyncWriteStream, Allocator, WriteHandler>(b, handler));
 }
 
 #endif // !defined(BOOST_NO_IOSTREAM)

Modified: trunk/boost/asio/impl/write_at.hpp
==============================================================================
--- trunk/boost/asio/impl/write_at.hpp (original)
+++ trunk/boost/asio/impl/write_at.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -22,6 +22,7 @@
 #include <boost/asio/detail/consuming_buffers.hpp>
 #include <boost/asio/detail/handler_alloc_helpers.hpp>
 #include <boost/asio/detail/handler_invoke_helpers.hpp>
+#include <boost/asio/detail/handler_type_requirements.hpp>
 #include <boost/asio/detail/throw_error.hpp>
 
 #include <boost/asio/detail/push_options.hpp>
@@ -64,6 +65,14 @@
   return bytes_transferred;
 }
 
+template <typename SyncRandomAccessWriteDevice, typename ConstBufferSequence>
+inline std::size_t write_at(SyncRandomAccessWriteDevice& d,
+ boost::uint64_t offset, const ConstBufferSequence& buffers,
+ boost::system::error_code& ec)
+{
+ return write_at(d, offset, buffers, transfer_all(), ec);
+}
+
 template <typename SyncRandomAccessWriteDevice, typename ConstBufferSequence,
     typename CompletionCondition>
 inline std::size_t write_at(SyncRandomAccessWriteDevice& d,
@@ -101,6 +110,14 @@
   return bytes_transferred;
 }
 
+template <typename SyncRandomAccessWriteDevice, typename Allocator>
+inline std::size_t write_at(SyncRandomAccessWriteDevice& d,
+ boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b,
+ boost::system::error_code& ec)
+{
+ return write_at(d, offset, b, transfer_all(), ec);
+}
+
 template <typename SyncRandomAccessWriteDevice, typename Allocator,
     typename CompletionCondition>
 inline std::size_t write_at(SyncRandomAccessWriteDevice& d,
@@ -126,14 +143,14 @@
   public:
     write_at_op(AsyncRandomAccessWriteDevice& device,
         boost::uint64_t offset, const ConstBufferSequence& buffers,
- CompletionCondition completion_condition, WriteHandler handler)
+ CompletionCondition completion_condition, WriteHandler& handler)
       : detail::base_from_completion_cond<
           CompletionCondition>(completion_condition),
         device_(device),
         offset_(offset),
         buffers_(buffers),
         total_transferred_(0),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))
     {
     }
 
@@ -180,14 +197,14 @@
     write_at_op(AsyncRandomAccessWriteDevice& device,
         boost::uint64_t offset, const boost::asio::mutable_buffers_1& buffers,
         CompletionCondition completion_condition,
- WriteHandler handler)
+ WriteHandler& handler)
       : detail::base_from_completion_cond<
           CompletionCondition>(completion_condition),
         device_(device),
         offset_(offset),
         buffer_(buffers),
         total_transferred_(0),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))
     {
     }
 
@@ -233,14 +250,14 @@
     write_at_op(AsyncRandomAccessWriteDevice& device,
         boost::uint64_t offset, const boost::asio::const_buffers_1& buffers,
         CompletionCondition completion_condition,
- WriteHandler handler)
+ WriteHandler& handler)
       : detail::base_from_completion_cond<
           CompletionCondition>(completion_condition),
         device_(device),
         offset_(offset),
         buffer_(buffers),
         total_transferred_(0),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))
     {
     }
 
@@ -314,6 +331,10 @@
     boost::uint64_t offset, const ConstBufferSequence& buffers,
     CompletionCondition completion_condition, WriteHandler handler)
 {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a WriteHandler.
+ BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
+
   detail::write_at_op<AsyncRandomAccessWriteDevice,
     ConstBufferSequence, CompletionCondition, WriteHandler>(
       d, offset, buffers, completion_condition, handler)(
@@ -326,7 +347,14 @@
     boost::uint64_t offset, const ConstBufferSequence& buffers,
     WriteHandler handler)
 {
- async_write_at(d, offset, buffers, transfer_all(), handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a WriteHandler.
+ BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
+
+ detail::write_at_op<AsyncRandomAccessWriteDevice,
+ ConstBufferSequence, detail::transfer_all_t, WriteHandler>(
+ d, offset, buffers, transfer_all(), handler)(
+ boost::system::error_code(), 0, 1);
 }
 
 #if !defined(BOOST_NO_IOSTREAM)
@@ -340,9 +368,9 @@
   public:
     write_at_streambuf_op(
         boost::asio::basic_streambuf<Allocator>& streambuf,
- WriteHandler handler)
+ WriteHandler& handler)
       : streambuf_(streambuf),
- handler_(handler)
+ handler_(BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))
     {
     }
 
@@ -395,6 +423,10 @@
     boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b,
     CompletionCondition completion_condition, WriteHandler handler)
 {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a WriteHandler.
+ BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
+
   async_write_at(d, offset, b.data(), completion_condition,
       detail::write_at_streambuf_op<
         AsyncRandomAccessWriteDevice, Allocator, WriteHandler>(b, handler));
@@ -406,7 +438,13 @@
     boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b,
     WriteHandler handler)
 {
- async_write_at(d, offset, b, transfer_all(), handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a WriteHandler.
+ BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
+
+ async_write_at(d, offset, b.data(), transfer_all(),
+ detail::write_at_streambuf_op<
+ AsyncRandomAccessWriteDevice, Allocator, WriteHandler>(b, handler));
 }
 
 #endif // !defined(BOOST_NO_IOSTREAM)

Modified: trunk/boost/asio/io_service.hpp
==============================================================================
--- trunk/boost/asio/io_service.hpp (original)
+++ trunk/boost/asio/io_service.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -256,8 +256,10 @@
    * waiting in the pool are equivalent and the io_service may choose any one
    * of them to invoke a handler.
    *
- * The run() function may be safely called again once it has completed only
- * after a call to reset().
+ * A normal exit from the run() function implies that the io_service object
+ * is stopped (the stopped() function returns @c true). Subsequent calls to
+ * run(), run_one(), poll() or poll_one() will return immediately unless there
+ * is a prior call to reset().
    *
    * @return The number of handlers that were executed.
    *
@@ -282,8 +284,10 @@
    * waiting in the pool are equivalent and the io_service may choose any one
    * of them to invoke a handler.
    *
- * The run() function may be safely called again once it has completed only
- * after a call to reset().
+ * A normal exit from the run() function implies that the io_service object
+ * is stopped (the stopped() function returns @c true). Subsequent calls to
+ * run(), run_one(), poll() or poll_one() will return immediately unless there
+ * is a prior call to reset().
    *
    * @param ec Set to indicate what error occurred, if any.
    *
@@ -304,7 +308,11 @@
    * The run_one() function blocks until one handler has been dispatched, or
    * until the io_service has been stopped.
    *
- * @return The number of handlers that were executed.
+ * @return The number of handlers that were executed. A zero return value
+ * implies that the io_service object is stopped (the stopped() function
+ * returns @c true). Subsequent calls to run(), run_one(), poll() or
+ * poll_one() will return immediately unless there is a prior call to
+ * reset().
    *
    * @throws boost::system::system_error Thrown on failure.
    */
@@ -316,7 +324,11 @@
    * The run_one() function blocks until one handler has been dispatched, or
    * until the io_service has been stopped.
    *
- * @param ec Set to indicate what error occurred, if any.
+ * @return The number of handlers that were executed. A zero return value
+ * implies that the io_service object is stopped (the stopped() function
+ * returns @c true). Subsequent calls to run(), run_one(), poll() or
+ * poll_one() will return immediately unless there is a prior call to
+ * reset().
    *
    * @return The number of handlers that were executed.
    */
@@ -379,13 +391,25 @@
    */
   BOOST_ASIO_DECL void stop();
 
+ /// Determine whether the io_service object has been stopped.
+ /**
+ * This function is used to determine whether an io_service object has been
+ * stopped, either through an explicit call to stop(), or due to running out
+ * of work. When an io_service object is stopped, calls to run(), run_one(),
+ * poll() or poll_one() will return immediately without invoking any
+ * handlers.
+ *
+ * @return @c true if the io_service object is stopped, otherwise @c false.
+ */
+ BOOST_ASIO_DECL bool stopped() const;
+
   /// Reset the io_service in preparation for a subsequent run() invocation.
   /**
    * This function must be called prior to any second or later set of
    * invocations of the run(), run_one(), poll() or poll_one() functions when a
    * previous invocation of these functions returned due to the io_service
- * being stopped or running out of work. This function allows the io_service
- * to reset any internal state, such as a "stopped" flag.
+ * being stopped or running out of work. After a call to reset(), the
+ * io_service object's stopped() function will return @c false.
    *
    * This function must not be called while there are any unfinished calls to
    * the run(), run_one(), poll() or poll_one() functions.
@@ -569,10 +593,6 @@
    */
   ~work();
 
- /// (Deprecated: use get_io_service().) Get the io_service associated with the
- /// work.
- boost::asio::io_service& io_service();
-
   /// Get the io_service associated with the work.
   boost::asio::io_service& get_io_service();
 
@@ -598,10 +618,6 @@
   : private noncopyable
 {
 public:
- /// (Deprecated: use get_io_service().) Get the io_service object that owns
- /// the service.
- boost::asio::io_service& io_service();
-
   /// Get the io_service object that owns the service.
   boost::asio::io_service& get_io_service();
 

Modified: trunk/boost/asio/ip/address.hpp
==============================================================================
--- trunk/boost/asio/ip/address.hpp (original)
+++ trunk/boost/asio/ip/address.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -108,6 +108,15 @@
   BOOST_ASIO_DECL static address from_string(
       const std::string& str, boost::system::error_code& ec);
 
+ /// Determine whether the address is a loopback address.
+ BOOST_ASIO_DECL bool is_loopback() const;
+
+ /// Determine whether the address is unspecified.
+ BOOST_ASIO_DECL bool is_unspecified() const;
+
+ /// Determine whether the address is a multicast address.
+ BOOST_ASIO_DECL bool is_multicast() const;
+
   /// Compare two addresses for equality.
   BOOST_ASIO_DECL friend bool operator==(const address& a1, const address& a2);
 

Modified: trunk/boost/asio/ip/address_v4.hpp
==============================================================================
--- trunk/boost/asio/ip/address_v4.hpp (original)
+++ trunk/boost/asio/ip/address_v4.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -98,6 +98,12 @@
   BOOST_ASIO_DECL static address_v4 from_string(
       const std::string& str, boost::system::error_code& ec);
 
+ /// Determine whether the address is a loopback address.
+ BOOST_ASIO_DECL bool is_loopback() const;
+
+ /// Determine whether the address is unspecified.
+ BOOST_ASIO_DECL bool is_unspecified() const;
+
   /// Determine whether the address is a class A address.
   BOOST_ASIO_DECL bool is_class_a() const;
 
@@ -149,19 +155,19 @@
   /// Obtain an address object that represents any address.
   static address_v4 any()
   {
- return address_v4(static_cast<unsigned long>(INADDR_ANY));
+ return address_v4();
   }
 
   /// Obtain an address object that represents the loopback address.
   static address_v4 loopback()
   {
- return address_v4(static_cast<unsigned long>(INADDR_LOOPBACK));
+ return address_v4(0x7F000001);
   }
 
   /// Obtain an address object that represents the broadcast address.
   static address_v4 broadcast()
   {
- return address_v4(static_cast<unsigned long>(INADDR_BROADCAST));
+ return address_v4(0xFFFFFFFF);
   }
 
   /// Obtain an address object that represents the broadcast address that

Modified: trunk/boost/asio/ip/basic_endpoint.hpp
==============================================================================
--- trunk/boost/asio/ip/basic_endpoint.hpp (original)
+++ trunk/boost/asio/ip/basic_endpoint.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -78,8 +78,9 @@
    * boost::asio::ip::udp::endpoint ep(boost::asio::ip::udp::v6(), 9876);
    * @endcode
    */
- basic_endpoint(const InternetProtocol& protocol, unsigned short port_num)
- : impl_(protocol.family(), port_num)
+ basic_endpoint(const InternetProtocol& internet_protocol,
+ unsigned short port_num)
+ : impl_(internet_protocol.family(), port_num)
   {
   }
 
@@ -131,9 +132,9 @@
   }
 
   /// Set the underlying size of the endpoint in the native type.
- void resize(std::size_t size)
+ void resize(std::size_t new_size)
   {
- impl_.resize(size);
+ impl_.resize(new_size);
   }
 
   /// Get the capacity of the endpoint in the native type.

Modified: trunk/boost/asio/ip/basic_resolver.hpp
==============================================================================
--- trunk/boost/asio/ip/basic_resolver.hpp (original)
+++ trunk/boost/asio/ip/basic_resolver.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -17,6 +17,7 @@
 
 #include <boost/asio/detail/config.hpp>
 #include <boost/asio/basic_io_object.hpp>
+#include <boost/asio/detail/handler_type_requirements.hpp>
 #include <boost/asio/detail/throw_error.hpp>
 #include <boost/asio/error.hpp>
 #include <boost/asio/ip/basic_resolver_iterator.hpp>
@@ -154,7 +155,13 @@
   template <typename ResolveHandler>
   void async_resolve(const query& q, ResolveHandler handler)
   {
- return this->service.async_resolve(this->implementation, q, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ResolveHandler.
+ BOOST_ASIO_RESOLVE_HANDLER_CHECK(
+ ResolveHandler, handler, iterator) type_check;
+
+ return this->service.async_resolve(this->implementation, q,
+ BOOST_ASIO_MOVE_CAST(ResolveHandler)(handler));
   }
 
   /// Perform reverse resolution of an endpoint to a list of entries.
@@ -238,7 +245,13 @@
   template <typename ResolveHandler>
   void async_resolve(const endpoint_type& e, ResolveHandler handler)
   {
- return this->service.async_resolve(this->implementation, e, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ResolveHandler.
+ BOOST_ASIO_RESOLVE_HANDLER_CHECK(
+ ResolveHandler, handler, iterator) type_check;
+
+ return this->service.async_resolve(this->implementation, e,
+ BOOST_ASIO_MOVE_CAST(ResolveHandler)(handler));
   }
 };
 

Modified: trunk/boost/asio/ip/basic_resolver_entry.hpp
==============================================================================
--- trunk/boost/asio/ip/basic_resolver_entry.hpp (original)
+++ trunk/boost/asio/ip/basic_resolver_entry.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -49,11 +49,11 @@
   }
 
   /// Construct with specified endpoint, host name and service name.
- basic_resolver_entry(const endpoint_type& endpoint,
- const std::string& host_name, const std::string& service_name)
- : endpoint_(endpoint),
- host_name_(host_name),
- service_name_(service_name)
+ basic_resolver_entry(const endpoint_type& ep,
+ const std::string& host, const std::string& service)
+ : endpoint_(ep),
+ host_name_(host),
+ service_name_(service)
   {
   }
 

Modified: trunk/boost/asio/ip/basic_resolver_query.hpp
==============================================================================
--- trunk/boost/asio/ip/basic_resolver_query.hpp (original)
+++ trunk/boost/asio/ip/basic_resolver_query.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -48,8 +48,8 @@
    * This constructor is typically used to perform name resolution for local
    * service binding.
    *
- * @param service_name A string identifying the requested service. This may
- * be a descriptive name or a numeric string corresponding to a port number.
+ * @param service A string identifying the requested service. This may be a
+ * descriptive name or a numeric string corresponding to a port number.
    *
    * @param resolve_flags A set of flags that determine how name resolution
    * should be performed. The default flags are suitable for local service
@@ -60,11 +60,11 @@
    * <tt>c:\\windows\\system32\\drivers\\etc\\services</tt>. Operating systems
    * may use additional locations when resolving service names.
    */
- basic_resolver_query(const std::string& service_name,
+ basic_resolver_query(const std::string& service,
       resolver_query_base::flags resolve_flags = passive | address_configured)
     : hints_(),
       host_name_(),
- service_name_(service_name)
+ service_name_(service)
   {
     typename InternetProtocol::endpoint endpoint;
     hints_.ai_flags = static_cast<int>(resolve_flags);
@@ -85,8 +85,8 @@
    * @param protocol A protocol object, normally representing either the IPv4 or
    * IPv6 version of an internet protocol.
    *
- * @param service_name A string identifying the requested service. This may
- * be a descriptive name or a numeric string corresponding to a port number.
+ * @param service A string identifying the requested service. This may be a
+ * descriptive name or a numeric string corresponding to a port number.
    *
    * @param resolve_flags A set of flags that determine how name resolution
    * should be performed. The default flags are suitable for local service
@@ -98,11 +98,11 @@
    * may use additional locations when resolving service names.
    */
   basic_resolver_query(const protocol_type& protocol,
- const std::string& service_name,
+ const std::string& service,
       resolver_query_base::flags resolve_flags = passive | address_configured)
     : hints_(),
       host_name_(),
- service_name_(service_name)
+ service_name_(service)
   {
     hints_.ai_flags = static_cast<int>(resolve_flags);
     hints_.ai_family = protocol.family();
@@ -119,16 +119,16 @@
    * This constructor is typically used to perform name resolution for
    * communication with remote hosts.
    *
- * @param host_name A string identifying a location. May be a descriptive name
- * or a numeric address string. If an empty string and the passive flag has
- * been specified, the resolved endpoints are suitable for local service
- * binding. If an empty string and passive is not specified, the resolved
- * endpoints will use the loopback address.
- *
- * @param service_name A string identifying the requested service. This may
- * be a descriptive name or a numeric string corresponding to a port number.
- * May be an empty string, in which case all resolved endpoints will have a
- * port number of 0.
+ * @param host A string identifying a location. May be a descriptive name or
+ * a numeric address string. If an empty string and the passive flag has been
+ * specified, the resolved endpoints are suitable for local service binding.
+ * If an empty string and passive is not specified, the resolved endpoints
+ * will use the loopback address.
+ *
+ * @param service A string identifying the requested service. This may be a
+ * descriptive name or a numeric string corresponding to a port number. May
+ * be an empty string, in which case all resolved endpoints will have a port
+ * number of 0.
    *
    * @param resolve_flags A set of flags that determine how name resolution
    * should be performed. The default flags are suitable for communication with
@@ -145,12 +145,11 @@
    * <tt>c:\\windows\\system32\\drivers\\etc\\services</tt>. Operating systems
    * may use additional locations when resolving service names.
    */
- basic_resolver_query(const std::string& host_name,
- const std::string& service_name,
+ basic_resolver_query(const std::string& host, const std::string& service,
       resolver_query_base::flags resolve_flags = address_configured)
     : hints_(),
- host_name_(host_name),
- service_name_(service_name)
+ host_name_(host),
+ service_name_(service)
   {
     typename InternetProtocol::endpoint endpoint;
     hints_.ai_flags = static_cast<int>(resolve_flags);
@@ -171,16 +170,16 @@
    * @param protocol A protocol object, normally representing either the IPv4 or
    * IPv6 version of an internet protocol.
    *
- * @param host_name A string identifying a location. May be a descriptive name
- * or a numeric address string. If an empty string and the passive flag has
- * been specified, the resolved endpoints are suitable for local service
- * binding. If an empty string and passive is not specified, the resolved
- * endpoints will use the loopback address.
- *
- * @param service_name A string identifying the requested service. This may
- * be a descriptive name or a numeric string corresponding to a port number.
- * May be an empty string, in which case all resolved endpoints will have a
- * port number of 0.
+ * @param host A string identifying a location. May be a descriptive name or
+ * a numeric address string. If an empty string and the passive flag has been
+ * specified, the resolved endpoints are suitable for local service binding.
+ * If an empty string and passive is not specified, the resolved endpoints
+ * will use the loopback address.
+ *
+ * @param service A string identifying the requested service. This may be a
+ * descriptive name or a numeric string corresponding to a port number. May
+ * be an empty string, in which case all resolved endpoints will have a port
+ * number of 0.
    *
    * @param resolve_flags A set of flags that determine how name resolution
    * should be performed. The default flags are suitable for communication with
@@ -198,11 +197,11 @@
    * may use additional locations when resolving service names.
    */
   basic_resolver_query(const protocol_type& protocol,
- const std::string& host_name, const std::string& service_name,
+ const std::string& host, const std::string& service,
       resolver_query_base::flags resolve_flags = address_configured)
     : hints_(),
- host_name_(host_name),
- service_name_(service_name)
+ host_name_(host),
+ service_name_(service)
   {
     hints_.ai_flags = static_cast<int>(resolve_flags);
     hints_.ai_family = protocol.family();

Modified: trunk/boost/asio/ip/detail/endpoint.hpp
==============================================================================
--- trunk/boost/asio/ip/detail/endpoint.hpp (original)
+++ trunk/boost/asio/ip/detail/endpoint.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -78,12 +78,12 @@
   }
 
   // Set the underlying size of the endpoint in the native type.
- BOOST_ASIO_DECL void resize(std::size_t size);
+ BOOST_ASIO_DECL void resize(std::size_t new_size);
 
   // Get the capacity of the endpoint in the native type.
   std::size_t capacity() const
   {
- return sizeof(boost::asio::detail::sockaddr_storage_type);
+ return sizeof(data_);
   }
 
   // Get the port associated with the endpoint.
@@ -122,7 +122,6 @@
   union data_union
   {
     boost::asio::detail::socket_addr_type base;
- boost::asio::detail::sockaddr_storage_type storage;
     boost::asio::detail::sockaddr_in4_type v4;
     boost::asio::detail::sockaddr_in6_type v6;
   } data_;

Modified: trunk/boost/asio/ip/detail/impl/endpoint.ipp
==============================================================================
--- trunk/boost/asio/ip/detail/impl/endpoint.ipp (original)
+++ trunk/boost/asio/ip/detail/impl/endpoint.ipp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -57,8 +57,14 @@
     data_.v6.sin6_port =
       boost::asio::detail::socket_ops::host_to_network_short(port_num);
     data_.v6.sin6_flowinfo = 0;
- boost::asio::detail::in6_addr_type tmp_addr = IN6ADDR_ANY_INIT;
- data_.v6.sin6_addr = tmp_addr;
+ data_.v6.sin6_addr.s6_addr[0] = 0; data_.v6.sin6_addr.s6_addr[1] = 0;
+ data_.v6.sin6_addr.s6_addr[2] = 0, data_.v6.sin6_addr.s6_addr[3] = 0;
+ data_.v6.sin6_addr.s6_addr[4] = 0, data_.v6.sin6_addr.s6_addr[5] = 0;
+ data_.v6.sin6_addr.s6_addr[6] = 0, data_.v6.sin6_addr.s6_addr[7] = 0;
+ data_.v6.sin6_addr.s6_addr[8] = 0, data_.v6.sin6_addr.s6_addr[9] = 0;
+ data_.v6.sin6_addr.s6_addr[10] = 0, data_.v6.sin6_addr.s6_addr[11] = 0;
+ data_.v6.sin6_addr.s6_addr[12] = 0, data_.v6.sin6_addr.s6_addr[13] = 0;
+ data_.v6.sin6_addr.s6_addr[14] = 0, data_.v6.sin6_addr.s6_addr[15] = 0;
     data_.v6.sin6_scope_id = 0;
   }
 }
@@ -90,9 +96,9 @@
   }
 }
 
-void endpoint::resize(std::size_t size)
+void endpoint::resize(std::size_t new_size)
 {
- if (size > sizeof(boost::asio::detail::sockaddr_storage_type))
+ if (new_size > sizeof(boost::asio::detail::sockaddr_storage_type))
   {
     boost::system::error_code ec(boost::asio::error::invalid_argument);
     boost::asio::detail::throw_error(ec);

Modified: trunk/boost/asio/ip/detail/socket_option.hpp
==============================================================================
--- trunk/boost/asio/ip/detail/socket_option.hpp (original)
+++ trunk/boost/asio/ip/detail/socket_option.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -385,31 +385,18 @@
 public:
   // Default constructor.
   multicast_request()
+ : ipv4_value_(), // Zero-initialisation gives the "any" address.
+ ipv6_value_() // Zero-initialisation gives the "any" address.
   {
- ipv4_value_.imr_multiaddr.s_addr =
- boost::asio::detail::socket_ops::host_to_network_long(
- boost::asio::ip::address_v4::any().to_ulong());
- ipv4_value_.imr_interface.s_addr =
- boost::asio::detail::socket_ops::host_to_network_long(
- boost::asio::ip::address_v4::any().to_ulong());
-
- boost::asio::detail::in6_addr_type tmp_addr = IN6ADDR_ANY_INIT;
- ipv6_value_.ipv6mr_multiaddr = tmp_addr;
- ipv6_value_.ipv6mr_interface = 0;
   }
 
   // Construct with multicast address only.
   explicit multicast_request(const boost::asio::ip::address& multicast_address)
+ : ipv4_value_(), // Zero-initialisation gives the "any" address.
+ ipv6_value_() // Zero-initialisation gives the "any" address.
   {
     if (multicast_address.is_v6())
     {
- ipv4_value_.imr_multiaddr.s_addr =
- boost::asio::detail::socket_ops::host_to_network_long(
- boost::asio::ip::address_v4::any().to_ulong());
- ipv4_value_.imr_interface.s_addr =
- boost::asio::detail::socket_ops::host_to_network_long(
- boost::asio::ip::address_v4::any().to_ulong());
-
       using namespace std; // For memcpy.
       boost::asio::ip::address_v6 ipv6_address = multicast_address.to_v6();
       boost::asio::ip::address_v6::bytes_type bytes = ipv6_address.to_bytes();
@@ -424,10 +411,6 @@
       ipv4_value_.imr_interface.s_addr =
         boost::asio::detail::socket_ops::host_to_network_long(
             boost::asio::ip::address_v4::any().to_ulong());
-
- boost::asio::detail::in6_addr_type tmp_addr = IN6ADDR_ANY_INIT;
- ipv6_value_.ipv6mr_multiaddr = tmp_addr;
- ipv6_value_.ipv6mr_interface = 0;
     }
   }
 
@@ -436,6 +419,7 @@
       const boost::asio::ip::address_v4& multicast_address,
       const boost::asio::ip::address_v4& network_interface
         = boost::asio::ip::address_v4::any())
+ : ipv6_value_() // Zero-initialisation gives the "any" address.
   {
     ipv4_value_.imr_multiaddr.s_addr =
       boost::asio::detail::socket_ops::host_to_network_long(
@@ -443,24 +427,14 @@
     ipv4_value_.imr_interface.s_addr =
       boost::asio::detail::socket_ops::host_to_network_long(
           network_interface.to_ulong());
-
- boost::asio::detail::in6_addr_type tmp_addr = IN6ADDR_ANY_INIT;
- ipv6_value_.ipv6mr_multiaddr = tmp_addr;
- ipv6_value_.ipv6mr_interface = 0;
   }
 
   // Construct with multicast address and IPv6 network interface index.
   explicit multicast_request(
       const boost::asio::ip::address_v6& multicast_address,
       unsigned long network_interface = 0)
+ : ipv4_value_() // Zero-initialisation gives the "any" address.
   {
- ipv4_value_.imr_multiaddr.s_addr =
- boost::asio::detail::socket_ops::host_to_network_long(
- boost::asio::ip::address_v4::any().to_ulong());
- ipv4_value_.imr_interface.s_addr =
- boost::asio::detail::socket_ops::host_to_network_long(
- boost::asio::ip::address_v4::any().to_ulong());
-
     using namespace std; // For memcpy.
     boost::asio::ip::address_v6::bytes_type bytes =
       multicast_address.to_bytes();

Modified: trunk/boost/asio/ip/icmp.hpp
==============================================================================
--- trunk/boost/asio/ip/icmp.hpp (original)
+++ trunk/boost/asio/ip/icmp.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -46,12 +46,6 @@
   /// The type of a ICMP endpoint.
   typedef basic_endpoint<icmp> endpoint;
 
- /// (Deprecated: use resolver::query.) The type of a resolver query.
- typedef basic_resolver_query<icmp> resolver_query;
-
- /// (Deprecated: use resolver::iterator.) The type of a resolver iterator.
- typedef basic_resolver_iterator<icmp> resolver_iterator;
-
   /// Construct to represent the IPv4 ICMP protocol.
   static icmp v4()
   {
@@ -102,9 +96,9 @@
 
 private:
   // Construct with a specific family.
- explicit icmp(int protocol, int family)
- : protocol_(protocol),
- family_(family)
+ explicit icmp(int protocol_id, int protocol_family)
+ : protocol_(protocol_id),
+ family_(protocol_family)
   {
   }
 

Modified: trunk/boost/asio/ip/impl/address.ipp
==============================================================================
--- trunk/boost/asio/ip/impl/address.ipp (original)
+++ trunk/boost/asio/ip/impl/address.ipp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -159,6 +159,27 @@
   return from_string(str.c_str(), ec);
 }
 
+bool address::is_loopback() const
+{
+ return (type_ == ipv4)
+ ? ipv4_address_.is_loopback()
+ : ipv6_address_.is_loopback();
+}
+
+bool address::is_unspecified() const
+{
+ return (type_ == ipv4)
+ ? ipv4_address_.is_unspecified()
+ : ipv6_address_.is_unspecified();
+}
+
+bool address::is_multicast() const
+{
+ return (type_ == ipv4)
+ ? ipv4_address_.is_multicast()
+ : ipv6_address_.is_multicast();
+}
+
 bool operator==(const address& a1, const address& a2)
 {
   if (a1.type_ != a2.type_)

Modified: trunk/boost/asio/ip/impl/address_v4.ipp
==============================================================================
--- trunk/boost/asio/ip/impl/address_v4.ipp (original)
+++ trunk/boost/asio/ip/impl/address_v4.ipp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -119,24 +119,34 @@
   return from_string(str.c_str(), ec);
 }
 
+bool address_v4::is_loopback() const
+{
+ return (to_ulong() & 0xFF000000) == 0x7F000000;
+}
+
+bool address_v4::is_unspecified() const
+{
+ return to_ulong() == 0;
+}
+
 bool address_v4::is_class_a() const
 {
- return IN_CLASSA(to_ulong());
+ return (to_ulong() & 0x80000000) == 0;
 }
 
 bool address_v4::is_class_b() const
 {
- return IN_CLASSB(to_ulong());
+ return (to_ulong() & 0xC0000000) == 0x80000000;
 }
 
 bool address_v4::is_class_c() const
 {
- return IN_CLASSC(to_ulong());
+ return (to_ulong() & 0xE0000000) == 0xC0000000;
 }
 
 bool address_v4::is_multicast() const
 {
- return IN_MULTICAST(to_ulong());
+ return (to_ulong() & 0xF0000000) == 0xE0000000;
 }
 
 address_v4 address_v4::broadcast(const address_v4& addr, const address_v4& mask)

Modified: trunk/boost/asio/ip/impl/address_v6.ipp
==============================================================================
--- trunk/boost/asio/ip/impl/address_v6.ipp (original)
+++ trunk/boost/asio/ip/impl/address_v6.ipp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -32,15 +32,14 @@
 namespace ip {
 
 address_v6::address_v6()
- : scope_id_(0)
+ : addr_(),
+ scope_id_(0)
 {
- boost::asio::detail::in6_addr_type tmp_addr = IN6ADDR_ANY_INIT;
- addr_ = tmp_addr;
 }
 
 address_v6::address_v6(const address_v6::bytes_type& bytes,
- unsigned long scope_id)
- : scope_id_(scope_id)
+ unsigned long scope)
+ : scope_id_(scope)
 {
 #if UCHAR_MAX > 0xFF
   for (std::size_t i = 0; i < bytes.size(); ++i)
@@ -141,7 +140,6 @@
 
 bool address_v6::is_loopback() const
 {
-#if defined(__BORLANDC__)
   return ((addr_.s6_addr[0] == 0) && (addr_.s6_addr[1] == 0)
       && (addr_.s6_addr[2] == 0) && (addr_.s6_addr[3] == 0)
       && (addr_.s6_addr[4] == 0) && (addr_.s6_addr[5] == 0)
@@ -150,15 +148,10 @@
       && (addr_.s6_addr[10] == 0) && (addr_.s6_addr[11] == 0)
       && (addr_.s6_addr[12] == 0) && (addr_.s6_addr[13] == 0)
       && (addr_.s6_addr[14] == 0) && (addr_.s6_addr[15] == 1));
-#else
- using namespace boost::asio::detail;
- return IN6_IS_ADDR_LOOPBACK(&addr_) != 0;
-#endif
 }
 
 bool address_v6::is_unspecified() const
 {
-#if defined(__BORLANDC__)
   return ((addr_.s6_addr[0] == 0) && (addr_.s6_addr[1] == 0)
       && (addr_.s6_addr[2] == 0) && (addr_.s6_addr[3] == 0)
       && (addr_.s6_addr[4] == 0) && (addr_.s6_addr[5] == 0)
@@ -167,70 +160,70 @@
       && (addr_.s6_addr[10] == 0) && (addr_.s6_addr[11] == 0)
       && (addr_.s6_addr[12] == 0) && (addr_.s6_addr[13] == 0)
       && (addr_.s6_addr[14] == 0) && (addr_.s6_addr[15] == 0));
-#else
- using namespace boost::asio::detail;
- return IN6_IS_ADDR_UNSPECIFIED(&addr_) != 0;
-#endif
 }
 
 bool address_v6::is_link_local() const
 {
- using namespace boost::asio::detail;
- return IN6_IS_ADDR_LINKLOCAL(&addr_) != 0;
+ return ((addr_.s6_addr[0] == 0xfe) && ((addr_.s6_addr[1] & 0xc0) == 0x80));
 }
 
 bool address_v6::is_site_local() const
 {
- using namespace boost::asio::detail;
- return IN6_IS_ADDR_SITELOCAL(&addr_) != 0;
+ return ((addr_.s6_addr[0] == 0xfe) && ((addr_.s6_addr[1] & 0xc0) == 0xc0));
 }
 
 bool address_v6::is_v4_mapped() const
 {
- using namespace boost::asio::detail;
- return IN6_IS_ADDR_V4MAPPED(&addr_) != 0;
+ return ((addr_.s6_addr[0] == 0) && (addr_.s6_addr[1] == 0)
+ && (addr_.s6_addr[2] == 0) && (addr_.s6_addr[3] == 0)
+ && (addr_.s6_addr[4] == 0) && (addr_.s6_addr[5] == 0)
+ && (addr_.s6_addr[6] == 0) && (addr_.s6_addr[7] == 0)
+ && (addr_.s6_addr[8] == 0) && (addr_.s6_addr[9] == 0)
+ && (addr_.s6_addr[10] == 0xff) && (addr_.s6_addr[11] == 0xff));
 }
 
 bool address_v6::is_v4_compatible() const
 {
- using namespace boost::asio::detail;
- return IN6_IS_ADDR_V4COMPAT(&addr_) != 0;
+ return ((addr_.s6_addr[0] == 0) && (addr_.s6_addr[1] == 0)
+ && (addr_.s6_addr[2] == 0) && (addr_.s6_addr[3] == 0)
+ && (addr_.s6_addr[4] == 0) && (addr_.s6_addr[5] == 0)
+ && (addr_.s6_addr[6] == 0) && (addr_.s6_addr[7] == 0)
+ && (addr_.s6_addr[8] == 0) && (addr_.s6_addr[9] == 0)
+ && (addr_.s6_addr[10] == 0) && (addr_.s6_addr[11] == 0)
+ && !((addr_.s6_addr[12] == 0)
+ && (addr_.s6_addr[13] == 0)
+ && (addr_.s6_addr[14] == 0)
+ && ((addr_.s6_addr[15] == 0) || (addr_.s6_addr[15] == 1))));
 }
 
 bool address_v6::is_multicast() const
 {
- using namespace boost::asio::detail;
- return IN6_IS_ADDR_MULTICAST(&addr_) != 0;
+ return (addr_.s6_addr[0] == 0xff);
 }
 
 bool address_v6::is_multicast_global() const
 {
- using namespace boost::asio::detail;
- return IN6_IS_ADDR_MC_GLOBAL(&addr_) != 0;
+ return ((addr_.s6_addr[0] == 0xff) && ((addr_.s6_addr[1] & 0x0f) == 0x0e));
 }
 
 bool address_v6::is_multicast_link_local() const
 {
- using namespace boost::asio::detail;
- return IN6_IS_ADDR_MC_LINKLOCAL(&addr_) != 0;
+ return ((addr_.s6_addr[0] == 0xff) && ((addr_.s6_addr[1] & 0x0f) == 0x02));
 }
 
 bool address_v6::is_multicast_node_local() const
 {
- using namespace boost::asio::detail;
- return IN6_IS_ADDR_MC_NODELOCAL(&addr_) != 0;
+ return ((addr_.s6_addr[0] == 0xff) && ((addr_.s6_addr[1] & 0x0f) == 0x01));
 }
 
 bool address_v6::is_multicast_org_local() const
 {
- using namespace boost::asio::detail;
- return IN6_IS_ADDR_MC_ORGLOCAL(&addr_) != 0;
+ return ((addr_.s6_addr[0] == 0xff) && ((addr_.s6_addr[1] & 0x0f) == 0x08));
 }
 
 bool address_v6::is_multicast_site_local() const
 {
- using namespace boost::asio::detail;
- return IN6_IS_ADDR_MC_SITELOCAL(&addr_) != 0;
+ return ((addr_.s6_addr[0] == 0xff) && ((addr_.s6_addr[1] & 0x0f) == 0x05));
 }
 
 bool operator==(const address_v6& a1, const address_v6& a2)
@@ -256,8 +249,7 @@
 address_v6 address_v6::loopback()
 {
   address_v6 tmp;
- boost::asio::detail::in6_addr_type tmp_addr = IN6ADDR_LOOPBACK_INIT;
- tmp.addr_ = tmp_addr;
+ tmp.addr_.s6_addr[15] = 1;
   return tmp;
 }
 

Modified: trunk/boost/asio/ip/tcp.hpp
==============================================================================
--- trunk/boost/asio/ip/tcp.hpp (original)
+++ trunk/boost/asio/ip/tcp.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -49,12 +49,6 @@
   /// The type of a TCP endpoint.
   typedef basic_endpoint<tcp> endpoint;
 
- /// (Deprecated: use resolver::query.) The type of a resolver query.
- typedef basic_resolver_query<tcp> resolver_query;
-
- /// (Deprecated: use resolver::iterator.) The type of a resolver iterator.
- typedef basic_resolver_iterator<tcp> resolver_iterator;
-
   /// Construct to represent the IPv4 TCP protocol.
   static tcp v4()
   {
@@ -146,8 +140,8 @@
 
 private:
   // Construct with a specific family.
- explicit tcp(int family)
- : family_(family)
+ explicit tcp(int protocol_family)
+ : family_(protocol_family)
   {
   }
 

Modified: trunk/boost/asio/ip/udp.hpp
==============================================================================
--- trunk/boost/asio/ip/udp.hpp (original)
+++ trunk/boost/asio/ip/udp.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -46,12 +46,6 @@
   /// The type of a UDP endpoint.
   typedef basic_endpoint<udp> endpoint;
 
- /// (Deprecated: use resolver::query.) The type of a resolver query.
- typedef basic_resolver_query<udp> resolver_query;
-
- /// (Deprecated: use resolver::iterator.) The type of a resolver iterator.
- typedef basic_resolver_iterator<udp> resolver_iterator;
-
   /// Construct to represent the IPv4 UDP protocol.
   static udp v4()
   {
@@ -102,8 +96,8 @@
 
 private:
   // Construct with a specific family.
- explicit udp(int family)
- : family_(family)
+ explicit udp(int protocol_family)
+ : family_(protocol_family)
   {
   }
 

Modified: trunk/boost/asio/local/basic_endpoint.hpp
==============================================================================
--- trunk/boost/asio/local/basic_endpoint.hpp (original)
+++ trunk/boost/asio/local/basic_endpoint.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -66,14 +66,14 @@
   }
 
   /// Construct an endpoint using the specified path name.
- basic_endpoint(const char* path)
- : impl_(path)
+ basic_endpoint(const char* path_name)
+ : impl_(path_name)
   {
   }
 
   /// Construct an endpoint using the specified path name.
- basic_endpoint(const std::string& path)
- : impl_(path)
+ basic_endpoint(const std::string& path_name)
+ : impl_(path_name)
   {
   }
 
@@ -115,9 +115,9 @@
   }
 
   /// Set the underlying size of the endpoint in the native type.
- void resize(std::size_t size)
+ void resize(std::size_t new_size)
   {
- impl_.resize(size);
+ impl_.resize(new_size);
   }
 
   /// Get the capacity of the endpoint in the native type.

Modified: trunk/boost/asio/local/detail/endpoint.hpp
==============================================================================
--- trunk/boost/asio/local/detail/endpoint.hpp (original)
+++ trunk/boost/asio/local/detail/endpoint.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -39,10 +39,10 @@
   BOOST_ASIO_DECL endpoint();
 
   // Construct an endpoint using the specified path name.
- BOOST_ASIO_DECL endpoint(const char* path);
+ BOOST_ASIO_DECL endpoint(const char* path_name);
 
   // Construct an endpoint using the specified path name.
- BOOST_ASIO_DECL endpoint(const std::string& path);
+ BOOST_ASIO_DECL endpoint(const std::string& path_name);
 
   // Copy constructor.
   endpoint(const endpoint& other)

Modified: trunk/boost/asio/local/detail/impl/endpoint.ipp
==============================================================================
--- trunk/boost/asio/local/detail/impl/endpoint.ipp (original)
+++ trunk/boost/asio/local/detail/impl/endpoint.ipp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -38,31 +38,31 @@
   init("", 0);
 }
 
-endpoint::endpoint(const char* path)
+endpoint::endpoint(const char* path_name)
 {
   using namespace std; // For strlen.
- init(path, strlen(path));
+ init(path_name, strlen(path_name));
 }
 
-endpoint::endpoint(const std::string& path)
+endpoint::endpoint(const std::string& path_name)
 {
- init(path.data(), path.length());
+ init(path_name.data(), path_name.length());
 }
 
-void endpoint::resize(std::size_t size)
+void endpoint::resize(std::size_t new_size)
 {
- if (size > sizeof(boost::asio::detail::sockaddr_un_type))
+ if (new_size > sizeof(boost::asio::detail::sockaddr_un_type))
   {
     boost::system::error_code ec(boost::asio::error::invalid_argument);
     boost::asio::detail::throw_error(ec);
   }
- else if (size == 0)
+ else if (new_size == 0)
   {
     path_length_ = 0;
   }
   else
   {
- path_length_ = size
+ path_length_ = new_size
       - offsetof(boost::asio::detail::sockaddr_un_type, sun_path);
 
     // The path returned by the operating system may be NUL-terminated.
@@ -97,7 +97,7 @@
   return e1.path() < e2.path();
 }
 
-void endpoint::init(const char* path, std::size_t path_length)
+void endpoint::init(const char* path_name, std::size_t path_length)
 {
   if (path_length > sizeof(data_.local.sun_path) - 1)
   {
@@ -109,7 +109,7 @@
   using namespace std; // For memcpy.
   data_.local = boost::asio::detail::sockaddr_un_type();
   data_.local.sun_family = AF_UNIX;
- memcpy(data_.local.sun_path, path, path_length);
+ memcpy(data_.local.sun_path, path_name, path_length);
   path_length_ = path_length;
 
   // NUL-terminate normal path names. Names that start with a NUL are in the

Modified: trunk/boost/asio/posix/basic_descriptor.hpp
==============================================================================
--- trunk/boost/asio/posix/basic_descriptor.hpp (original)
+++ trunk/boost/asio/posix/basic_descriptor.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -46,8 +46,12 @@
     public descriptor_base
 {
 public:
+ /// (Deprecated: Use native_handle_type.) The native representation of a
+ /// descriptor.
+ typedef typename DescriptorService::native_handle_type native_type;
+
   /// The native representation of a descriptor.
- typedef typename DescriptorService::native_type native_type;
+ typedef typename DescriptorService::native_handle_type native_handle_type;
 
   /// A basic_descriptor is always the lowest layer.
   typedef basic_descriptor<DescriptorService> lowest_layer_type;
@@ -79,7 +83,7 @@
    * @throws boost::system::system_error Thrown on failure.
    */
   basic_descriptor(boost::asio::io_service& io_service,
- const native_type& native_descriptor)
+ const native_handle_type& native_descriptor)
     : basic_io_object<DescriptorService>(io_service)
   {
     boost::system::error_code ec;
@@ -123,7 +127,7 @@
    *
    * @throws boost::system::system_error Thrown on failure.
    */
- void assign(const native_type& native_descriptor)
+ void assign(const native_handle_type& native_descriptor)
   {
     boost::system::error_code ec;
     this->service.assign(this->implementation, native_descriptor, ec);
@@ -138,7 +142,7 @@
    *
    * @param ec Set to indicate what error occurred, if any.
    */
- boost::system::error_code assign(const native_type& native_descriptor,
+ boost::system::error_code assign(const native_handle_type& native_descriptor,
       boost::system::error_code& ec)
   {
     return this->service.assign(this->implementation, native_descriptor, ec);
@@ -178,7 +182,8 @@
     return this->service.close(this->implementation, ec);
   }
 
- /// Get the native descriptor representation.
+ /// (Deprecated: Use native_handle().) Get the native descriptor
+ /// representation.
   /**
    * This function may be used to obtain the underlying representation of the
    * descriptor. This is intended to allow access to native descriptor
@@ -186,7 +191,33 @@
    */
   native_type native()
   {
- return this->service.native(this->implementation);
+ return this->service.native_handle(this->implementation);
+ }
+
+ /// Get the native descriptor representation.
+ /**
+ * This function may be used to obtain the underlying representation of the
+ * descriptor. This is intended to allow access to native descriptor
+ * functionality that is not otherwise provided.
+ */
+ native_handle_type native_handle()
+ {
+ return this->service.native_handle(this->implementation);
+ }
+
+ /// Release ownership of the native descriptor implementation.
+ /**
+ * This function may be used to obtain the underlying representation of the
+ * descriptor. After calling this function, @c is_open() returns false. The
+ * caller is responsible for closing the descriptor.
+ *
+ * All outstanding asynchronous read or write operations will finish
+ * immediately, and the handlers for cancelled operations will be passed the
+ * boost::asio::error::operation_aborted error.
+ */
+ native_handle_type release()
+ {
+ return this->service.release(this->implementation);
   }
 
   /// Cancel all asynchronous operations associated with the descriptor.
@@ -281,6 +312,123 @@
     return this->service.io_control(this->implementation, command, ec);
   }
 
+ /// Gets the non-blocking mode of the descriptor.
+ /**
+ * @returns @c true if the descriptor's synchronous operations will fail with
+ * boost::asio::error::would_block if they are unable to perform the requested
+ * operation immediately. If @c false, synchronous operations will block
+ * until complete.
+ *
+ * @note The non-blocking mode has no effect on the behaviour of asynchronous
+ * operations. Asynchronous operations will never fail with the error
+ * boost::asio::error::would_block.
+ */
+ bool non_blocking() const
+ {
+ return this->service.non_blocking(this->implementation);
+ }
+
+ /// Sets the non-blocking mode of the descriptor.
+ /**
+ * @param mode If @c true, the descriptor's synchronous operations will fail
+ * with boost::asio::error::would_block if they are unable to perform the
+ * requested operation immediately. If @c false, synchronous operations will
+ * block until complete.
+ *
+ * @throws boost::system::system_error Thrown on failure.
+ *
+ * @note The non-blocking mode has no effect on the behaviour of asynchronous
+ * operations. Asynchronous operations will never fail with the error
+ * boost::asio::error::would_block.
+ */
+ void non_blocking(bool mode)
+ {
+ boost::system::error_code ec;
+ this->service.non_blocking(this->implementation, mode, ec);
+ boost::asio::detail::throw_error(ec);
+ }
+
+ /// Sets the non-blocking mode of the descriptor.
+ /**
+ * @param mode If @c true, the descriptor's synchronous operations will fail
+ * with boost::asio::error::would_block if they are unable to perform the
+ * requested operation immediately. If @c false, synchronous operations will
+ * block until complete.
+ *
+ * @param ec Set to indicate what error occurred, if any.
+ *
+ * @note The non-blocking mode has no effect on the behaviour of asynchronous
+ * operations. Asynchronous operations will never fail with the error
+ * boost::asio::error::would_block.
+ */
+ boost::system::error_code non_blocking(
+ bool mode, boost::system::error_code& ec)
+ {
+ return this->service.non_blocking(this->implementation, mode, ec);
+ }
+
+ /// Gets the non-blocking mode of the native descriptor implementation.
+ /**
+ * This function is used to retrieve the non-blocking mode of the underlying
+ * native descriptor. This mode has no effect on the behaviour of the
+ * descriptor object's synchronous operations.
+ *
+ * @returns @c true if the underlying descriptor is in non-blocking mode and
+ * direct system calls may fail with boost::asio::error::would_block (or the
+ * equivalent system error).
+ *
+ * @note The current non-blocking mode is cached by the descriptor object.
+ * Consequently, the return value may be incorrect if the non-blocking mode
+ * was set directly on the native descriptor.
+ */
+ bool native_non_blocking() const
+ {
+ return this->service.native_non_blocking(this->implementation);
+ }
+
+ /// Sets the non-blocking mode of the native descriptor implementation.
+ /**
+ * This function is used to modify the non-blocking mode of the underlying
+ * native descriptor. It has no effect on the behaviour of the descriptor
+ * object's synchronous operations.
+ *
+ * @param mode If @c true, the underlying descriptor is put into non-blocking
+ * mode and direct system calls may fail with boost::asio::error::would_block
+ * (or the equivalent system error).
+ *
+ * @throws boost::system::system_error Thrown on failure. If the @c mode is
+ * @c false, but the current value of @c non_blocking() is @c true, this
+ * function fails with boost::asio::error::invalid_argument, as the
+ * combination does not make sense.
+ */
+ void native_non_blocking(bool mode)
+ {
+ boost::system::error_code ec;
+ this->service.native_non_blocking(this->implementation, mode, ec);
+ boost::asio::detail::throw_error(ec);
+ }
+
+ /// Sets the non-blocking mode of the native descriptor implementation.
+ /**
+ * This function is used to modify the non-blocking mode of the underlying
+ * native descriptor. It has no effect on the behaviour of the descriptor
+ * object's synchronous operations.
+ *
+ * @param mode If @c true, the underlying descriptor is put into non-blocking
+ * mode and direct system calls may fail with boost::asio::error::would_block
+ * (or the equivalent system error).
+ *
+ * @param ec Set to indicate what error occurred, if any. If the @c mode is
+ * @c false, but the current value of @c non_blocking() is @c true, this
+ * function fails with boost::asio::error::invalid_argument, as the
+ * combination does not make sense.
+ */
+ boost::system::error_code native_non_blocking(
+ bool mode, boost::system::error_code& ec)
+ {
+ return this->service.native_non_blocking(this->implementation, mode, ec);
+ }
+
 protected:
   /// Protected destructor to prevent deletion through this type.
   ~basic_descriptor()

Modified: trunk/boost/asio/posix/basic_stream_descriptor.hpp
==============================================================================
--- trunk/boost/asio/posix/basic_stream_descriptor.hpp (original)
+++ trunk/boost/asio/posix/basic_stream_descriptor.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -21,6 +21,7 @@
   || defined(GENERATING_DOCUMENTATION)
 
 #include <cstddef>
+#include <boost/asio/detail/handler_type_requirements.hpp>
 #include <boost/asio/detail/throw_error.hpp>
 #include <boost/asio/error.hpp>
 #include <boost/asio/posix/basic_descriptor.hpp>
@@ -49,8 +50,13 @@
   : public basic_descriptor<StreamDescriptorService>
 {
 public:
+ /// (Deprecated: Use native_handle_type.) The native representation of a
+ /// descriptor.
+ typedef typename StreamDescriptorService::native_handle_type native_type;
+
   /// The native representation of a descriptor.
- typedef typename StreamDescriptorService::native_type native_type;
+ typedef typename StreamDescriptorService::native_handle_type
+ native_handle_type;
 
   /// Construct a basic_stream_descriptor without opening it.
   /**
@@ -81,7 +87,7 @@
    * @throws boost::system::system_error Thrown on failure.
    */
   basic_stream_descriptor(boost::asio::io_service& io_service,
- const native_type& native_descriptor)
+ const native_handle_type& native_descriptor)
     : basic_descriptor<StreamDescriptorService>(io_service, native_descriptor)
   {
   }
@@ -184,7 +190,12 @@
   void async_write_some(const ConstBufferSequence& buffers,
       WriteHandler handler)
   {
- this->service.async_write_some(this->implementation, buffers, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a WriteHandler.
+ BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
+
+ this->service.async_write_some(this->implementation, buffers,
+ BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
   /// Read some data from the descriptor.
@@ -288,7 +299,12 @@
   void async_read_some(const MutableBufferSequence& buffers,
       ReadHandler handler)
   {
- this->service.async_read_some(this->implementation, buffers, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
+ this->service.async_read_some(this->implementation, buffers,
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 };
 

Modified: trunk/boost/asio/posix/descriptor_base.hpp
==============================================================================
--- trunk/boost/asio/posix/descriptor_base.hpp (original)
+++ trunk/boost/asio/posix/descriptor_base.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -35,7 +35,8 @@
 class descriptor_base
 {
 public:
- /// IO control command to set the blocking mode of the descriptor.
+ /// (Deprecated: Use non_blocking().) IO control command to set the blocking
+ /// mode of the descriptor.
   /**
    * Implements the FIONBIO IO control command.
    *

Modified: trunk/boost/asio/posix/stream_descriptor_service.hpp
==============================================================================
--- trunk/boost/asio/posix/stream_descriptor_service.hpp (original)
+++ trunk/boost/asio/posix/stream_descriptor_service.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -57,11 +57,18 @@
   typedef service_impl_type::implementation_type implementation_type;
 #endif
 
- /// The native descriptor type.
+ /// (Deprecated: Use native_handle_type.) The native descriptor type.
 #if defined(GENERATING_DOCUMENTATION)
   typedef implementation_defined native_type;
 #else
- typedef service_impl_type::native_type native_type;
+ typedef service_impl_type::native_handle_type native_type;
+#endif
+
+ /// The native descriptor type.
+#if defined(GENERATING_DOCUMENTATION)
+ typedef implementation_defined native_handle_type;
+#else
+ typedef service_impl_type::native_handle_type native_handle_type;
 #endif
 
   /// Construct a new stream descriptor service for the specified io_service.
@@ -71,7 +78,7 @@
   {
   }
 
- /// Destroy all user-defined descriptorr objects owned by the service.
+ /// Destroy all user-defined handler objects owned by the service.
   void shutdown_service()
   {
     service_impl_.shutdown_service();
@@ -91,7 +98,8 @@
 
   /// Assign an existing native descriptor to a stream descriptor.
   boost::system::error_code assign(implementation_type& impl,
- const native_type& native_descriptor, boost::system::error_code& ec)
+ const native_handle_type& native_descriptor,
+ boost::system::error_code& ec)
   {
     return service_impl_.assign(impl, native_descriptor, ec);
   }
@@ -109,10 +117,23 @@
     return service_impl_.close(impl, ec);
   }
 
- /// Get the native descriptor implementation.
+ /// (Deprecated: Use native_handle().) Get the native descriptor
+ /// implementation.
   native_type native(implementation_type& impl)
   {
- return service_impl_.native(impl);
+ return service_impl_.native_handle(impl);
+ }
+
+ /// Get the native descriptor implementation.
+ native_handle_type native_handle(implementation_type& impl)
+ {
+ return service_impl_.native_handle(impl);
+ }
+
+ /// Release ownership of the native descriptor implementation.
+ native_handle_type release(implementation_type& impl)
+ {
+ return service_impl_.release(impl);
   }
 
   /// Cancel all asynchronous operations associated with the descriptor.
@@ -130,6 +151,32 @@
     return service_impl_.io_control(impl, command, ec);
   }
 
+ /// Gets the non-blocking mode of the descriptor.
+ bool non_blocking(const implementation_type& impl) const
+ {
+ return service_impl_.non_blocking(impl);
+ }
+
+ /// Sets the non-blocking mode of the descriptor.
+ boost::system::error_code non_blocking(implementation_type& impl,
+ bool mode, boost::system::error_code& ec)
+ {
+ return service_impl_.non_blocking(impl, mode, ec);
+ }
+
+ /// Gets the non-blocking mode of the native descriptor implementation.
+ bool native_non_blocking(const implementation_type& impl) const
+ {
+ return service_impl_.native_non_blocking(impl);
+ }
+
+ /// Sets the non-blocking mode of the native descriptor implementation.
+ boost::system::error_code native_non_blocking(implementation_type& impl,
+ bool mode, boost::system::error_code& ec)
+ {
+ return service_impl_.native_non_blocking(impl, mode, ec);
+ }
+
   /// Write the given data to the stream.
   template <typename ConstBufferSequence>
   std::size_t write_some(implementation_type& impl,
@@ -141,9 +188,9 @@
   /// Start an asynchronous write.
   template <typename ConstBufferSequence, typename WriteHandler>
   void async_write_some(implementation_type& impl,
- const ConstBufferSequence& buffers, WriteHandler descriptorr)
+ const ConstBufferSequence& buffers, WriteHandler handler)
   {
- service_impl_.async_write_some(impl, buffers, descriptorr);
+ service_impl_.async_write_some(impl, buffers, handler);
   }
 
   /// Read some data from the stream.
@@ -157,9 +204,9 @@
   /// Start an asynchronous read.
   template <typename MutableBufferSequence, typename ReadHandler>
   void async_read_some(implementation_type& impl,
- const MutableBufferSequence& buffers, ReadHandler descriptorr)
+ const MutableBufferSequence& buffers, ReadHandler handler)
   {
- service_impl_.async_read_some(impl, buffers, descriptorr);
+ service_impl_.async_read_some(impl, buffers, handler);
   }
 
 private:

Modified: trunk/boost/asio/raw_socket_service.hpp
==============================================================================
--- trunk/boost/asio/raw_socket_service.hpp (original)
+++ trunk/boost/asio/raw_socket_service.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -68,11 +68,18 @@
   typedef typename service_impl_type::implementation_type implementation_type;
 #endif
 
- /// The native socket type.
+ /// (Deprecated: Use native_handle_type.) The native socket type.
 #if defined(GENERATING_DOCUMENTATION)
   typedef implementation_defined native_type;
 #else
- typedef typename service_impl_type::native_type native_type;
+ typedef typename service_impl_type::native_handle_type native_type;
+#endif
+
+ /// The native socket type.
+#if defined(GENERATING_DOCUMENTATION)
+ typedef implementation_defined native_handle_type;
+#else
+ typedef typename service_impl_type::native_handle_type native_handle_type;
 #endif
 
   /// Construct a new raw socket service for the specified io_service.
@@ -114,7 +121,7 @@
 
   /// Assign an existing native socket to a raw socket.
   boost::system::error_code assign(implementation_type& impl,
- const protocol_type& protocol, const native_type& native_socket,
+ const protocol_type& protocol, const native_handle_type& native_socket,
       boost::system::error_code& ec)
   {
     return service_impl_.assign(impl, protocol, native_socket, ec);
@@ -133,10 +140,16 @@
     return service_impl_.close(impl, ec);
   }
 
- /// Get the native socket implementation.
+ /// (Deprecated: Use native_handle().) Get the native socket implementation.
   native_type native(implementation_type& impl)
   {
- return service_impl_.native(impl);
+ return service_impl_.native_handle(impl);
+ }
+
+ /// Get the native socket implementation.
+ native_handle_type native_handle(implementation_type& impl)
+ {
+ return service_impl_.native_handle(impl);
   }
 
   /// Cancel all asynchronous operations associated with the socket.
@@ -206,6 +219,32 @@
     return service_impl_.io_control(impl, command, ec);
   }
 
+ /// Gets the non-blocking mode of the socket.
+ bool non_blocking(const implementation_type& impl) const
+ {
+ return service_impl_.non_blocking(impl);
+ }
+
+ /// Sets the non-blocking mode of the socket.
+ boost::system::error_code non_blocking(implementation_type& impl,
+ bool mode, boost::system::error_code& ec)
+ {
+ return service_impl_.non_blocking(impl, mode, ec);
+ }
+
+ /// Gets the non-blocking mode of the native socket implementation.
+ bool native_non_blocking(const implementation_type& impl) const
+ {
+ return service_impl_.native_non_blocking(impl);
+ }
+
+ /// Sets the non-blocking mode of the native socket implementation.
+ boost::system::error_code native_non_blocking(implementation_type& impl,
+ bool mode, boost::system::error_code& ec)
+ {
+ return service_impl_.native_non_blocking(impl, mode, ec);
+ }
+
   /// Get the local endpoint.
   endpoint_type local_endpoint(const implementation_type& impl,
       boost::system::error_code& ec) const

Modified: trunk/boost/asio/read.hpp
==============================================================================
--- trunk/boost/asio/read.hpp (original)
+++ trunk/boost/asio/read.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -80,6 +80,46 @@
  * @li The supplied buffers are full. That is, the bytes transferred is equal to
  * the sum of the buffer sizes.
  *
+ * @li An error occurred.
+ *
+ * This operation is implemented in terms of zero or more calls to the stream's
+ * read_some function.
+ *
+ * @param s The stream from which the data is to be read. The type must support
+ * the SyncReadStream concept.
+ *
+ * @param buffers One or more buffers into which the data will be read. The sum
+ * of the buffer sizes indicates the maximum number of bytes to read from the
+ * stream.
+ *
+ * @param ec Set to indicate what error occurred, if any.
+ *
+ * @returns The number of bytes transferred.
+ *
+ * @par Example
+ * To read into a single data buffer use the @ref buffer function as follows:
+ * @code boost::asio::read(s, boost::asio::buffer(data, size), ec); @endcode
+ * See the @ref buffer documentation for information on reading into multiple
+ * buffers in one go, and how to use it with arrays, boost::array or
+ * std::vector.
+ *
+ * @note This overload is equivalent to calling:
+ * @code boost::asio::read(
+ * s, buffers,
+ * boost::asio::transfer_all(), ec); @endcode
+ */
+template <typename SyncReadStream, typename MutableBufferSequence>
+std::size_t read(SyncReadStream& s, const MutableBufferSequence& buffers,
+ boost::system::error_code& ec);
+
+/// Attempt to read a certain amount of data from a stream before returning.
+/**
+ * This function is used to read a certain number of bytes of data from a
+ * stream. The call will block until one of the following conditions is true:
+ *
+ * @li The supplied buffers are full. That is, the bytes transferred is equal to
+ * the sum of the buffer sizes.
+ *
  * @li The completion_condition function object returns 0.
  *
  * This operation is implemented in terms of zero or more calls to the stream's
@@ -201,6 +241,34 @@
  * This function is used to read a certain number of bytes of data from a
  * stream. The call will block until one of the following conditions is true:
  *
+ * @li An error occurred.
+ *
+ * This operation is implemented in terms of zero or more calls to the stream's
+ * read_some function.
+ *
+ * @param s The stream from which the data is to be read. The type must support
+ * the SyncReadStream concept.
+ *
+ * @param b The basic_streambuf object into which the data will be read.
+ *
+ * @param ec Set to indicate what error occurred, if any.
+ *
+ * @returns The number of bytes transferred.
+ *
+ * @note This overload is equivalent to calling:
+ * @code boost::asio::read(
+ * s, b,
+ * boost::asio::transfer_all(), ec); @endcode
+ */
+template <typename SyncReadStream, typename Allocator>
+std::size_t read(SyncReadStream& s, basic_streambuf<Allocator>& b,
+ boost::system::error_code& ec);
+
+/// Attempt to read a certain amount of data from a stream before returning.
+/**
+ * This function is used to read a certain number of bytes of data from a
+ * stream. The call will block until one of the following conditions is true:
+ *
  * @li The completion_condition function object returns 0.
  *
  * This operation is implemented in terms of zero or more calls to the stream's

Modified: trunk/boost/asio/read_at.hpp
==============================================================================
--- trunk/boost/asio/read_at.hpp (original)
+++ trunk/boost/asio/read_at.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -88,6 +88,52 @@
  * @li The supplied buffers are full. That is, the bytes transferred is equal to
  * the sum of the buffer sizes.
  *
+ * @li An error occurred.
+ *
+ * This operation is implemented in terms of zero or more calls to the device's
+ * read_some_at function.
+ *
+ * @param d The device from which the data is to be read. The type must support
+ * the SyncRandomAccessReadDevice concept.
+ *
+ * @param offset The offset at which the data will be read.
+ *
+ * @param buffers One or more buffers into which the data will be read. The sum
+ * of the buffer sizes indicates the maximum number of bytes to read from the
+ * device.
+ *
+ * @param ec Set to indicate what error occurred, if any.
+ *
+ * @returns The number of bytes transferred.
+ *
+ * @par Example
+ * To read into a single data buffer use the @ref buffer function as follows:
+ * @code boost::asio::read_at(d, 42,
+ * boost::asio::buffer(data, size), ec); @endcode
+ * See the @ref buffer documentation for information on reading into multiple
+ * buffers in one go, and how to use it with arrays, boost::array or
+ * std::vector.
+ *
+ * @note This overload is equivalent to calling:
+ * @code boost::asio::read_at(
+ * d, 42, buffers,
+ * boost::asio::transfer_all(), ec); @endcode
+ */
+template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence>
+std::size_t read_at(SyncRandomAccessReadDevice& d,
+ boost::uint64_t offset, const MutableBufferSequence& buffers,
+ boost::system::error_code& ec);
+
+/// Attempt to read a certain amount of data at the specified offset before
+/// returning.
+/**
+ * This function is used to read a certain number of bytes of data from a
+ * random access device at the specified offset. The call will block until one
+ * of the following conditions is true:
+ *
+ * @li The supplied buffers are full. That is, the bytes transferred is equal to
+ * the sum of the buffer sizes.
+ *
  * @li The completion_condition function object returns 0.
  *
  * This operation is implemented in terms of zero or more calls to the device's
@@ -224,6 +270,39 @@
  * random access device at the specified offset. The call will block until one
  * of the following conditions is true:
  *
+ * @li An error occurred.
+ *
+ * This operation is implemented in terms of zero or more calls to the device's
+ * read_some_at function.
+ *
+ * @param d The device from which the data is to be read. The type must support
+ * the SyncRandomAccessReadDevice concept.
+ *
+ * @param offset The offset at which the data will be read.
+ *
+ * @param b The basic_streambuf object into which the data will be read.
+ *
+ * @param ec Set to indicate what error occurred, if any.
+ *
+ * @returns The number of bytes transferred.
+ *
+ * @note This overload is equivalent to calling:
+ * @code boost::asio::read_at(
+ * d, 42, b,
+ * boost::asio::transfer_all(), ec); @endcode
+ */
+template <typename SyncRandomAccessReadDevice, typename Allocator>
+std::size_t read_at(SyncRandomAccessReadDevice& d,
+ boost::uint64_t offset, basic_streambuf<Allocator>& b,
+ boost::system::error_code& ec);
+
+/// Attempt to read a certain amount of data at the specified offset before
+/// returning.
+/**
+ * This function is used to read a certain number of bytes of data from a
+ * random access device at the specified offset. The call will block until one
+ * of the following conditions is true:
+ *
  * @li The completion_condition function object returns 0.
  *
  * This operation is implemented in terms of zero or more calls to the device's

Added: trunk/boost/asio/seq_packet_socket_service.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/asio/seq_packet_socket_service.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -0,0 +1,319 @@
+//
+// seq_packet_socket_service.hpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// 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)
+//
+
+#ifndef BOOST_ASIO_SEQ_PACKET_SOCKET_SERVICE_HPP
+#define BOOST_ASIO_SEQ_PACKET_SOCKET_SERVICE_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
+
+#include <boost/asio/detail/config.hpp>
+#include <cstddef>
+#include <boost/asio/error.hpp>
+#include <boost/asio/io_service.hpp>
+
+#if defined(BOOST_ASIO_HAS_IOCP)
+# include <boost/asio/detail/win_iocp_socket_service.hpp>
+#else
+# include <boost/asio/detail/reactive_socket_service.hpp>
+#endif
+
+#include <boost/asio/detail/push_options.hpp>
+
+namespace boost {
+namespace asio {
+
+/// Default service implementation for a sequenced packet socket.
+template <typename Protocol>
+class seq_packet_socket_service
+#if defined(GENERATING_DOCUMENTATION)
+ : public boost::asio::io_service::service
+#else
+ : public boost::asio::detail::service_base<
+ seq_packet_socket_service<Protocol> >
+#endif
+{
+public:
+#if defined(GENERATING_DOCUMENTATION)
+ /// The unique service identifier.
+ static boost::asio::io_service::id id;
+#endif
+
+ /// The protocol type.
+ typedef Protocol protocol_type;
+
+ /// The endpoint type.
+ typedef typename Protocol::endpoint endpoint_type;
+
+private:
+ // The type of the platform-specific implementation.
+#if defined(BOOST_ASIO_HAS_IOCP)
+ typedef detail::win_iocp_socket_service<Protocol> service_impl_type;
+#else
+ typedef detail::reactive_socket_service<Protocol> service_impl_type;
+#endif
+
+public:
+ /// The type of a sequenced packet socket implementation.
+#if defined(GENERATING_DOCUMENTATION)
+ typedef implementation_defined implementation_type;
+#else
+ typedef typename service_impl_type::implementation_type implementation_type;
+#endif
+
+ /// (Deprecated: Use native_handle_type.) The native socket type.
+#if defined(GENERATING_DOCUMENTATION)
+ typedef implementation_defined native_type;
+#else
+ typedef typename service_impl_type::native_handle_type native_type;
+#endif
+
+ /// The native socket type.
+#if defined(GENERATING_DOCUMENTATION)
+ typedef implementation_defined native_handle_type;
+#else
+ typedef typename service_impl_type::native_handle_type native_handle_type;
+#endif
+
+ /// Construct a new sequenced packet socket service for the specified
+ /// io_service.
+ explicit seq_packet_socket_service(boost::asio::io_service& io_service)
+ : boost::asio::detail::service_base<
+ seq_packet_socket_service<Protocol> >(io_service),
+ service_impl_(io_service)
+ {
+ }
+
+ /// Destroy all user-defined handler objects owned by the service.
+ void shutdown_service()
+ {
+ service_impl_.shutdown_service();
+ }
+
+ /// Construct a new sequenced packet socket implementation.
+ void construct(implementation_type& impl)
+ {
+ service_impl_.construct(impl);
+ }
+
+ /// Destroy a sequenced packet socket implementation.
+ void destroy(implementation_type& impl)
+ {
+ service_impl_.destroy(impl);
+ }
+
+ /// Open a sequenced packet socket.
+ boost::system::error_code open(implementation_type& impl,
+ const protocol_type& protocol, boost::system::error_code& ec)
+ {
+ if (protocol.type() == SOCK_SEQPACKET)
+ service_impl_.open(impl, protocol, ec);
+ else
+ ec = boost::asio::error::invalid_argument;
+ return ec;
+ }
+
+ /// Assign an existing native socket to a sequenced packet socket.
+ boost::system::error_code assign(implementation_type& impl,
+ const protocol_type& protocol, const native_handle_type& native_socket,
+ boost::system::error_code& ec)
+ {
+ return service_impl_.assign(impl, protocol, native_socket, ec);
+ }
+
+ /// Determine whether the socket is open.
+ bool is_open(const implementation_type& impl) const
+ {
+ return service_impl_.is_open(impl);
+ }
+
+ /// Close a sequenced packet socket implementation.
+ boost::system::error_code close(implementation_type& impl,
+ boost::system::error_code& ec)
+ {
+ return service_impl_.close(impl, ec);
+ }
+
+ /// (Deprecated: Use native_handle().) Get the native socket implementation.
+ native_type native(implementation_type& impl)
+ {
+ return service_impl_.native_handle(impl);
+ }
+
+ /// Get the native socket implementation.
+ native_handle_type native_handle(implementation_type& impl)
+ {
+ return service_impl_.native_handle(impl);
+ }
+
+ /// Cancel all asynchronous operations associated with the socket.
+ boost::system::error_code cancel(implementation_type& impl,
+ boost::system::error_code& ec)
+ {
+ return service_impl_.cancel(impl, ec);
+ }
+
+ /// Determine whether the socket is at the out-of-band data mark.
+ bool at_mark(const implementation_type& impl,
+ boost::system::error_code& ec) const
+ {
+ return service_impl_.at_mark(impl, ec);
+ }
+
+ /// Determine the number of bytes available for reading.
+ std::size_t available(const implementation_type& impl,
+ boost::system::error_code& ec) const
+ {
+ return service_impl_.available(impl, ec);
+ }
+
+ /// Bind the sequenced packet socket to the specified local endpoint.
+ boost::system::error_code bind(implementation_type& impl,
+ const endpoint_type& endpoint, boost::system::error_code& ec)
+ {
+ return service_impl_.bind(impl, endpoint, ec);
+ }
+
+ /// Connect the sequenced packet socket to the specified endpoint.
+ boost::system::error_code connect(implementation_type& impl,
+ const endpoint_type& peer_endpoint, boost::system::error_code& ec)
+ {
+ return service_impl_.connect(impl, peer_endpoint, ec);
+ }
+
+ /// Start an asynchronous connect.
+ template <typename ConnectHandler>
+ void async_connect(implementation_type& impl,
+ const endpoint_type& peer_endpoint, ConnectHandler handler)
+ {
+ service_impl_.async_connect(impl, peer_endpoint, handler);
+ }
+
+ /// Set a socket option.
+ template <typename SettableSocketOption>
+ boost::system::error_code set_option(implementation_type& impl,
+ const SettableSocketOption& option, boost::system::error_code& ec)
+ {
+ return service_impl_.set_option(impl, option, ec);
+ }
+
+ /// Get a socket option.
+ template <typename GettableSocketOption>
+ boost::system::error_code get_option(const implementation_type& impl,
+ GettableSocketOption& option, boost::system::error_code& ec) const
+ {
+ return service_impl_.get_option(impl, option, ec);
+ }
+
+ /// Perform an IO control command on the socket.
+ template <typename IoControlCommand>
+ boost::system::error_code io_control(implementation_type& impl,
+ IoControlCommand& command, boost::system::error_code& ec)
+ {
+ return service_impl_.io_control(impl, command, ec);
+ }
+
+ /// Gets the non-blocking mode of the socket.
+ bool non_blocking(const implementation_type& impl) const
+ {
+ return service_impl_.non_blocking(impl);
+ }
+
+ /// Sets the non-blocking mode of the socket.
+ boost::system::error_code non_blocking(implementation_type& impl,
+ bool mode, boost::system::error_code& ec)
+ {
+ return service_impl_.non_blocking(impl, mode, ec);
+ }
+
+ /// Gets the non-blocking mode of the native socket implementation.
+ bool native_non_blocking(const implementation_type& impl) const
+ {
+ return service_impl_.native_non_blocking(impl);
+ }
+
+ /// Sets the non-blocking mode of the native socket implementation.
+ boost::system::error_code native_non_blocking(implementation_type& impl,
+ bool mode, boost::system::error_code& ec)
+ {
+ return service_impl_.native_non_blocking(impl, mode, ec);
+ }
+
+ /// Get the local endpoint.
+ endpoint_type local_endpoint(const implementation_type& impl,
+ boost::system::error_code& ec) const
+ {
+ return service_impl_.local_endpoint(impl, ec);
+ }
+
+ /// Get the remote endpoint.
+ endpoint_type remote_endpoint(const implementation_type& impl,
+ boost::system::error_code& ec) const
+ {
+ return service_impl_.remote_endpoint(impl, ec);
+ }
+
+ /// Disable sends or receives on the socket.
+ boost::system::error_code shutdown(implementation_type& impl,
+ socket_base::shutdown_type what, boost::system::error_code& ec)
+ {
+ return service_impl_.shutdown(impl, what, ec);
+ }
+
+ /// Send the given data to the peer.
+ template <typename ConstBufferSequence>
+ std::size_t send(implementation_type& impl,
+ const ConstBufferSequence& buffers,
+ socket_base::message_flags flags, boost::system::error_code& ec)
+ {
+ return service_impl_.send(impl, buffers, flags, ec);
+ }
+
+ /// Start an asynchronous send.
+ template <typename ConstBufferSequence, typename WriteHandler>
+ void async_send(implementation_type& impl,
+ const ConstBufferSequence& buffers,
+ socket_base::message_flags flags, WriteHandler handler)
+ {
+ service_impl_.async_send(impl, buffers, flags, handler);
+ }
+
+ /// Receive some data from the peer.
+ template <typename MutableBufferSequence>
+ std::size_t receive(implementation_type& impl,
+ const MutableBufferSequence& buffers, socket_base::message_flags in_flags,
+ socket_base::message_flags& out_flags, boost::system::error_code& ec)
+ {
+ return service_impl_.receive_with_flags(impl,
+ buffers, in_flags, out_flags, ec);
+ }
+
+ /// Start an asynchronous receive.
+ template <typename MutableBufferSequence, typename ReadHandler>
+ void async_receive(implementation_type& impl,
+ const MutableBufferSequence& buffers, socket_base::message_flags in_flags,
+ socket_base::message_flags& out_flags, ReadHandler handler)
+ {
+ service_impl_.async_receive_with_flags(impl,
+ buffers, in_flags, out_flags, handler);
+ }
+
+private:
+ // The platform-specific implementation.
+ service_impl_type service_impl_;
+};
+
+} // namespace asio
+} // namespace boost
+
+#include <boost/asio/detail/pop_options.hpp>
+
+#endif // BOOST_ASIO_SEQ_PACKET_SOCKET_SERVICE_HPP

Modified: trunk/boost/asio/serial_port_service.hpp
==============================================================================
--- trunk/boost/asio/serial_port_service.hpp (original)
+++ trunk/boost/asio/serial_port_service.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -63,11 +63,18 @@
   typedef service_impl_type::implementation_type implementation_type;
 #endif
 
- /// The native handle type.
+ /// (Deprecated: Use native_handle_type.) The native handle type.
 #if defined(GENERATING_DOCUMENTATION)
   typedef implementation_defined native_type;
 #else
- typedef service_impl_type::native_type native_type;
+ typedef service_impl_type::native_handle_type native_type;
+#endif
+
+ /// The native handle type.
+#if defined(GENERATING_DOCUMENTATION)
+ typedef implementation_defined native_handle_type;
+#else
+ typedef service_impl_type::native_handle_type native_handle_type;
 #endif
 
   /// Construct a new serial port service for the specified io_service.
@@ -104,9 +111,9 @@
 
   /// Assign an existing native handle to a serial port.
   boost::system::error_code assign(implementation_type& impl,
- const native_type& native_handle, boost::system::error_code& ec)
+ const native_handle_type& handle, boost::system::error_code& ec)
   {
- return service_impl_.assign(impl, native_handle, ec);
+ return service_impl_.assign(impl, handle, ec);
   }
 
   /// Determine whether the handle is open.
@@ -122,10 +129,16 @@
     return service_impl_.close(impl, ec);
   }
 
- /// Get the native handle implementation.
+ /// (Deprecated: Use native_handle().) Get the native handle implementation.
   native_type native(implementation_type& impl)
   {
- return service_impl_.native(impl);
+ return service_impl_.native_handle(impl);
+ }
+
+ /// Get the native handle implementation.
+ native_handle_type native_handle(implementation_type& impl)
+ {
+ return service_impl_.native_handle(impl);
   }
 
   /// Cancel all asynchronous operations associated with the handle.

Modified: trunk/boost/asio/socket_acceptor_service.hpp
==============================================================================
--- trunk/boost/asio/socket_acceptor_service.hpp (original)
+++ trunk/boost/asio/socket_acceptor_service.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -68,11 +68,18 @@
   typedef typename service_impl_type::implementation_type implementation_type;
 #endif
 
- /// The native acceptor type.
+ /// (Deprecated: Use native_handle_type.) The native acceptor type.
 #if defined(GENERATING_DOCUMENTATION)
   typedef implementation_defined native_type;
 #else
- typedef typename service_impl_type::native_type native_type;
+ typedef typename service_impl_type::native_handle_type native_type;
+#endif
+
+ /// The native acceptor type.
+#if defined(GENERATING_DOCUMENTATION)
+ typedef implementation_defined native_handle_type;
+#else
+ typedef typename service_impl_type::native_handle_type native_handle_type;
 #endif
 
   /// Construct a new socket acceptor service for the specified io_service.
@@ -110,7 +117,7 @@
 
   /// Assign an existing native acceptor to a socket acceptor.
   boost::system::error_code assign(implementation_type& impl,
- const protocol_type& protocol, const native_type& native_acceptor,
+ const protocol_type& protocol, const native_handle_type& native_acceptor,
       boost::system::error_code& ec)
   {
     return service_impl_.assign(impl, protocol, native_acceptor, ec);
@@ -151,10 +158,16 @@
     return service_impl_.close(impl, ec);
   }
 
- /// Get the native acceptor implementation.
+ /// (Deprecated: Use native_handle().) Get the native acceptor implementation.
   native_type native(implementation_type& impl)
   {
- return service_impl_.native(impl);
+ return service_impl_.native_handle(impl);
+ }
+
+ /// Get the native acceptor implementation.
+ native_handle_type native_handle(implementation_type& impl)
+ {
+ return service_impl_.native_handle(impl);
   }
 
   /// Set a socket option.
@@ -181,6 +194,32 @@
     return service_impl_.io_control(impl, command, ec);
   }
 
+ /// Gets the non-blocking mode of the acceptor.
+ bool non_blocking(const implementation_type& impl) const
+ {
+ return service_impl_.non_blocking(impl);
+ }
+
+ /// Sets the non-blocking mode of the acceptor.
+ boost::system::error_code non_blocking(implementation_type& impl,
+ bool mode, boost::system::error_code& ec)
+ {
+ return service_impl_.non_blocking(impl, mode, ec);
+ }
+
+ /// Gets the non-blocking mode of the native acceptor implementation.
+ bool native_non_blocking(const implementation_type& impl) const
+ {
+ return service_impl_.native_non_blocking(impl);
+ }
+
+ /// Sets the non-blocking mode of the native acceptor implementation.
+ boost::system::error_code native_non_blocking(implementation_type& impl,
+ bool mode, boost::system::error_code& ec)
+ {
+ return service_impl_.native_non_blocking(impl, mode, ec);
+ }
+
   /// Get the local endpoint.
   endpoint_type local_endpoint(const implementation_type& impl,
       boost::system::error_code& ec) const

Modified: trunk/boost/asio/socket_base.hpp
==============================================================================
--- trunk/boost/asio/socket_base.hpp (original)
+++ trunk/boost/asio/socket_base.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -63,6 +63,9 @@
 
   /// Specify that the data should not be subject to routing.
   static const int message_do_not_route = implementation_defined;
+
+ /// Specifies that the data marks the end of a record.
+ static const int message_end_of_record = implementation_defined;
 #else
   BOOST_STATIC_CONSTANT(int,
       message_peek = boost::asio::detail::message_peek);
@@ -70,6 +73,8 @@
       message_out_of_band = boost::asio::detail::message_out_of_band);
   BOOST_STATIC_CONSTANT(int,
       message_do_not_route = boost::asio::detail::message_do_not_route);
+ BOOST_STATIC_CONSTANT(int,
+ message_end_of_record = boost::asio::detail::message_end_of_record);
 #endif
 
   /// Socket option to permit sending of broadcast messages.
@@ -442,7 +447,8 @@
     enable_connection_aborted;
 #endif
 
- /// IO control command to set the blocking mode of the socket.
+ /// (Deprecated: Use non_blocking().) IO control command to
+ /// set the blocking mode of the socket.
   /**
    * Implements the FIONBIO IO control command.
    *

Modified: trunk/boost/asio/ssl.hpp
==============================================================================
--- trunk/boost/asio/ssl.hpp (original)
+++ trunk/boost/asio/ssl.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -19,6 +19,7 @@
 #include <boost/asio/ssl/context.hpp>
 #include <boost/asio/ssl/context_base.hpp>
 #include <boost/asio/ssl/context_service.hpp>
+#include <boost/asio/ssl/error.hpp>
 #include <boost/asio/ssl/stream.hpp>
 #include <boost/asio/ssl/stream_base.hpp>
 #include <boost/asio/ssl/stream_service.hpp>

Modified: trunk/boost/asio/ssl/detail/openssl_operation.hpp
==============================================================================
--- trunk/boost/asio/ssl/detail/openssl_operation.hpp (original)
+++ trunk/boost/asio/ssl/detail/openssl_operation.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -23,6 +23,7 @@
 #include <boost/asio/detail/socket_ops.hpp>
 #include <boost/asio/placeholders.hpp>
 #include <boost/asio/ssl/detail/openssl_types.hpp>
+#include <boost/asio/ssl/error.hpp>
 #include <boost/asio/strand.hpp>
 #include <boost/system/system_error.hpp>
 #include <boost/asio/write.hpp>

Added: trunk/boost/asio/ssl/error.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/asio/ssl/error.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -0,0 +1,72 @@
+//
+// ssl/error.hpp
+// ~~~~~~~~~~~~~
+//
+// 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)
+//
+
+#ifndef BOOST_ASIO_SSL_ERROR_HPP
+#define BOOST_ASIO_SSL_ERROR_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
+
+#include <boost/asio/detail/config.hpp>
+#include <boost/system/error_code.hpp>
+
+#include <boost/asio/detail/push_options.hpp>
+
+namespace boost {
+namespace asio {
+namespace error {
+
+enum ssl_errors
+{
+};
+
+extern BOOST_ASIO_DECL
+const boost::system::error_category& get_ssl_category();
+
+static const boost::system::error_category& ssl_category
+ = boost::asio::error::get_ssl_category();
+
+} // namespace error
+} // namespace asio
+} // namespace boost
+
+namespace boost {
+namespace system {
+
+template<> struct is_error_code_enum<boost::asio::error::ssl_errors>
+{
+ static const bool value = true;
+};
+
+} // namespace system
+} // namespace boost
+
+namespace boost {
+namespace asio {
+namespace error {
+
+inline boost::system::error_code make_error_code(ssl_errors e)
+{
+ return boost::system::error_code(
+ static_cast<int>(e), get_ssl_category());
+}
+
+} // namespace error
+} // namespace asio
+} // namespace boost
+
+#include <boost/asio/detail/pop_options.hpp>
+
+#if defined(BOOST_ASIO_HEADER_ONLY)
+# include <boost/asio/ssl/impl/error.ipp>
+#endif // defined(BOOST_ASIO_HEADER_ONLY)
+
+#endif // BOOST_ASIO_SSL_ERROR_HPP

Added: trunk/boost/asio/ssl/impl/error.ipp
==============================================================================
--- (empty file)
+++ trunk/boost/asio/ssl/impl/error.ipp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -0,0 +1,59 @@
+//
+// ssl/impl/error.ipp
+// ~~~~~~~~~~~~~~~~~~
+//
+// 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)
+//
+
+#ifndef BOOST_ASIO_SSL_IMPL_ERROR_IPP
+#define BOOST_ASIO_SSL_IMPL_ERROR_IPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
+
+#include <boost/asio/detail/config.hpp>
+#include <boost/asio/ssl/error.hpp>
+#include <boost/asio/ssl/detail/openssl_init.hpp>
+
+#include <boost/asio/detail/push_options.hpp>
+
+namespace boost {
+namespace asio {
+namespace error {
+
+namespace detail {
+
+class ssl_category : public boost::system::error_category
+{
+public:
+ const char* name() const
+ {
+ return "asio.ssl";
+ }
+
+ std::string message(int value) const
+ {
+ const char* s = ::ERR_reason_error_string(value);
+ return s ? s : "asio.ssl error";
+ }
+};
+
+} // namespace detail
+
+const boost::system::error_category& get_ssl_category()
+{
+ static detail::ssl_category instance;
+ return instance;
+}
+
+} // namespace error
+} // namespace asio
+} // namespace boost
+
+#include <boost/asio/detail/pop_options.hpp>
+
+#endif // BOOST_ASIO_SSL_IMPL_ERROR_IPP

Added: trunk/boost/asio/ssl/impl/src.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/asio/ssl/impl/src.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -0,0 +1,24 @@
+//
+// impl/ssl/src.hpp
+// ~~~~~~~~~~~~~~~~
+//
+// 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)
+//
+
+#ifndef BOOST_ASIO_IMPL_SRC_HPP
+#define BOOST_ASIO_IMPL_SRC_HPP
+
+#define BOOST_ASIO_SOURCE
+
+#include <boost/asio/detail/config.hpp>
+
+#if defined(BOOST_ASIO_HEADER_ONLY)
+# error Do not compile Asio library source with BOOST_ASIO_HEADER_ONLY defined
+#endif
+
+#include <boost/asio/ssl/impl/error.ipp>
+
+#endif // BOOST_ASIO_IMPL_SRC_HPP

Modified: trunk/boost/asio/ssl/stream.hpp
==============================================================================
--- trunk/boost/asio/ssl/stream.hpp (original)
+++ trunk/boost/asio/ssl/stream.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -94,20 +94,6 @@
     service_.destroy(impl_, next_layer_);
   }
 
- /// (Deprecated: use get_io_service().) Get the io_service associated with
- /// the object.
- /**
- * This function may be used to obtain the io_service object that the stream
- * uses to dispatch handlers for asynchronous operations.
- *
- * @return A reference to the io_service object that stream will use to
- * dispatch handlers. Ownership is not transferred to the caller.
- */
- boost::asio::io_service& io_service()
- {
- return next_layer_.get_io_service();
- }
-
   /// Get the io_service associated with the object.
   /**
    * This function may be used to obtain the io_service object that the stream

Modified: trunk/boost/asio/strand.hpp
==============================================================================
--- trunk/boost/asio/strand.hpp (original)
+++ trunk/boost/asio/strand.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -16,6 +16,7 @@
 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
 
 #include <boost/asio/detail/config.hpp>
+#include <boost/asio/detail/handler_type_requirements.hpp>
 #include <boost/asio/detail/strand_service.hpp>
 #include <boost/asio/detail/wrapped_handler.hpp>
 #include <boost/asio/io_service.hpp>
@@ -107,20 +108,6 @@
     service_.destroy(impl_);
   }
 
- /// (Deprecated: use get_io_service().) Get the io_service associated with
- /// the strand.
- /**
- * This function may be used to obtain the io_service object that the strand
- * uses to dispatch handlers for asynchronous operations.
- *
- * @return A reference to the io_service object that the strand will use to
- * dispatch handlers. Ownership is not transferred to the caller.
- */
- boost::asio::io_service& io_service()
- {
- return service_.get_io_service();
- }
-
   /// Get the io_service associated with the strand.
   /**
    * This function may be used to obtain the io_service object that the strand
@@ -153,9 +140,13 @@
    * handler object as required. The function signature of the handler must be:
    * @code void handler(); @endcode
    */
- template <typename Handler>
- void dispatch(Handler handler)
+ template <typename CompletionHandler>
+ void dispatch(CompletionHandler handler)
   {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a CompletionHandler.
+ BOOST_ASIO_COMPLETION_HANDLER_CHECK(CompletionHandler, handler) type_check;
+
     service_.dispatch(impl_, handler);
   }
 
@@ -175,9 +166,13 @@
    * handler object as required. The function signature of the handler must be:
    * @code void handler(); @endcode
    */
- template <typename Handler>
- void post(Handler handler)
+ template <typename CompletionHandler>
+ void post(CompletionHandler handler)
   {
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a CompletionHandler.
+ BOOST_ASIO_COMPLETION_HANDLER_CHECK(CompletionHandler, handler) type_check;
+
     service_.post(impl_, handler);
   }
 

Modified: trunk/boost/asio/stream_socket_service.hpp
==============================================================================
--- trunk/boost/asio/stream_socket_service.hpp (original)
+++ trunk/boost/asio/stream_socket_service.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -68,11 +68,18 @@
   typedef typename service_impl_type::implementation_type implementation_type;
 #endif
 
- /// The native socket type.
+ /// (Deprecated: Use native_handle_type.) The native socket type.
 #if defined(GENERATING_DOCUMENTATION)
   typedef implementation_defined native_type;
 #else
- typedef typename service_impl_type::native_type native_type;
+ typedef typename service_impl_type::native_handle_type native_type;
+#endif
+
+ /// The native socket type.
+#if defined(GENERATING_DOCUMENTATION)
+ typedef implementation_defined native_handle_type;
+#else
+ typedef typename service_impl_type::native_handle_type native_handle_type;
 #endif
 
   /// Construct a new stream socket service for the specified io_service.
@@ -114,7 +121,7 @@
 
   /// Assign an existing native socket to a stream socket.
   boost::system::error_code assign(implementation_type& impl,
- const protocol_type& protocol, const native_type& native_socket,
+ const protocol_type& protocol, const native_handle_type& native_socket,
       boost::system::error_code& ec)
   {
     return service_impl_.assign(impl, protocol, native_socket, ec);
@@ -133,10 +140,16 @@
     return service_impl_.close(impl, ec);
   }
 
- /// Get the native socket implementation.
+ /// (Deprecated: Use native_handle().) Get the native socket implementation.
   native_type native(implementation_type& impl)
   {
- return service_impl_.native(impl);
+ return service_impl_.native_handle(impl);
+ }
+
+ /// Get the native socket implementation.
+ native_handle_type native_handle(implementation_type& impl)
+ {
+ return service_impl_.native_handle(impl);
   }
 
   /// Cancel all asynchronous operations associated with the socket.
@@ -206,6 +219,32 @@
     return service_impl_.io_control(impl, command, ec);
   }
 
+ /// Gets the non-blocking mode of the socket.
+ bool non_blocking(const implementation_type& impl) const
+ {
+ return service_impl_.non_blocking(impl);
+ }
+
+ /// Sets the non-blocking mode of the socket.
+ boost::system::error_code non_blocking(implementation_type& impl,
+ bool mode, boost::system::error_code& ec)
+ {
+ return service_impl_.non_blocking(impl, mode, ec);
+ }
+
+ /// Gets the non-blocking mode of the native socket implementation.
+ bool native_non_blocking(const implementation_type& impl) const
+ {
+ return service_impl_.native_non_blocking(impl);
+ }
+
+ /// Sets the non-blocking mode of the native socket implementation.
+ boost::system::error_code native_non_blocking(implementation_type& impl,
+ bool mode, boost::system::error_code& ec)
+ {
+ return service_impl_.native_non_blocking(impl, mode, ec);
+ }
+
   /// Get the local endpoint.
   endpoint_type local_endpoint(const implementation_type& impl,
       boost::system::error_code& ec) const

Modified: trunk/boost/asio/version.hpp
==============================================================================
--- trunk/boost/asio/version.hpp (original)
+++ trunk/boost/asio/version.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -18,6 +18,6 @@
 // BOOST_ASIO_VERSION % 100 is the sub-minor version
 // BOOST_ASIO_VERSION / 100 % 1000 is the minor version
 // BOOST_ASIO_VERSION / 100000 is the major version
-#define BOOST_ASIO_VERSION 100408 // 1.4.8
+#define BOOST_ASIO_VERSION 100500 // 1.5.0
 
 #endif // BOOST_ASIO_VERSION_HPP

Modified: trunk/boost/asio/windows/basic_handle.hpp
==============================================================================
--- trunk/boost/asio/windows/basic_handle.hpp (original)
+++ trunk/boost/asio/windows/basic_handle.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -45,8 +45,12 @@
   : public basic_io_object<HandleService>
 {
 public:
+ /// (Deprecated: Use native_handle_type.) The native representation of a
+ /// handle.
+ typedef typename HandleService::native_handle_type native_type;
+
   /// The native representation of a handle.
- typedef typename HandleService::native_type native_type;
+ typedef typename HandleService::native_handle_type native_handle_type;
 
   /// A basic_handle is always the lowest layer.
   typedef basic_handle<HandleService> lowest_layer_type;
@@ -70,16 +74,16 @@
    * @param io_service The io_service object that the handle will use to
    * dispatch handlers for any asynchronous operations performed on the handle.
    *
- * @param native_handle A native handle.
+ * @param handle A native handle.
    *
    * @throws boost::system::system_error Thrown on failure.
    */
   basic_handle(boost::asio::io_service& io_service,
- const native_type& native_handle)
+ const native_handle_type& handle)
     : basic_io_object<HandleService>(io_service)
   {
     boost::system::error_code ec;
- this->service.assign(this->implementation, native_handle, ec);
+ this->service.assign(this->implementation, handle, ec);
     boost::asio::detail::throw_error(ec);
   }
 
@@ -115,14 +119,14 @@
   /*
    * This function opens the handle to hold an existing native handle.
    *
- * @param native_handle A native handle.
+ * @param handle A native handle.
    *
    * @throws boost::system::system_error Thrown on failure.
    */
- void assign(const native_type& native_handle)
+ void assign(const native_handle_type& handle)
   {
     boost::system::error_code ec;
- this->service.assign(this->implementation, native_handle, ec);
+ this->service.assign(this->implementation, handle, ec);
     boost::asio::detail::throw_error(ec);
   }
 
@@ -130,14 +134,14 @@
   /*
    * This function opens the handle to hold an existing native handle.
    *
- * @param native_handle A native handle.
+ * @param handle A native handle.
    *
    * @param ec Set to indicate what error occurred, if any.
    */
- boost::system::error_code assign(const native_type& native_handle,
+ boost::system::error_code assign(const native_handle_type& handle,
       boost::system::error_code& ec)
   {
- return this->service.assign(this->implementation, native_handle, ec);
+ return this->service.assign(this->implementation, handle, ec);
   }
 
   /// Determine whether the handle is open.
@@ -174,7 +178,7 @@
     return this->service.close(this->implementation, ec);
   }
 
- /// Get the native handle representation.
+ /// (Deprecated: Use native_handle().) Get the native handle representation.
   /**
    * This function may be used to obtain the underlying representation of the
    * handle. This is intended to allow access to native handle functionality
@@ -182,7 +186,18 @@
    */
   native_type native()
   {
- return this->service.native(this->implementation);
+ return this->service.native_handle(this->implementation);
+ }
+
+ /// Get the native handle representation.
+ /**
+ * This function may be used to obtain the underlying representation of the
+ * handle. This is intended to allow access to native handle functionality
+ * that is not otherwise provided.
+ */
+ native_handle_type native_handle()
+ {
+ return this->service.native_handle(this->implementation);
   }
 
   /// Cancel all asynchronous operations associated with the handle.

Modified: trunk/boost/asio/windows/basic_random_access_handle.hpp
==============================================================================
--- trunk/boost/asio/windows/basic_random_access_handle.hpp (original)
+++ trunk/boost/asio/windows/basic_random_access_handle.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -21,6 +21,7 @@
   || defined(GENERATING_DOCUMENTATION)
 
 #include <cstddef>
+#include <boost/asio/detail/handler_type_requirements.hpp>
 #include <boost/asio/detail/throw_error.hpp>
 #include <boost/asio/error.hpp>
 #include <boost/asio/windows/basic_handle.hpp>
@@ -46,8 +47,13 @@
   : public basic_handle<RandomAccessHandleService>
 {
 public:
+ /// (Deprecated: Use native_handle_type.) The native representation of a
+ /// handle.
+ typedef typename RandomAccessHandleService::native_handle_type native_type;
+
   /// The native representation of a handle.
- typedef typename RandomAccessHandleService::native_type native_type;
+ typedef typename RandomAccessHandleService::native_handle_type
+ native_handle_type;
 
   /// Construct a basic_random_access_handle without opening it.
   /**
@@ -72,13 +78,13 @@
    * use to dispatch handlers for any asynchronous operations performed on the
    * handle.
    *
- * @param native_handle The new underlying handle implementation.
+ * @param handle The new underlying handle implementation.
    *
    * @throws boost::system::system_error Thrown on failure.
    */
   basic_random_access_handle(boost::asio::io_service& io_service,
- const native_type& native_handle)
- : basic_handle<RandomAccessHandleService>(io_service, native_handle)
+ const native_handle_type& handle)
+ : basic_handle<RandomAccessHandleService>(io_service, handle)
   {
   }
 
@@ -189,8 +195,12 @@
   void async_write_some_at(boost::uint64_t offset,
       const ConstBufferSequence& buffers, WriteHandler handler)
   {
- this->service.async_write_some_at(
- this->implementation, offset, buffers, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a WriteHandler.
+ BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
+
+ this->service.async_write_some_at(this->implementation,
+ offset, buffers, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
   /// Read some data from the handle at the specified offset.
@@ -303,8 +313,12 @@
   void async_read_some_at(boost::uint64_t offset,
       const MutableBufferSequence& buffers, ReadHandler handler)
   {
- this->service.async_read_some_at(
- this->implementation, offset, buffers, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
+ this->service.async_read_some_at(this->implementation,
+ offset, buffers, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 };
 

Modified: trunk/boost/asio/windows/basic_stream_handle.hpp
==============================================================================
--- trunk/boost/asio/windows/basic_stream_handle.hpp (original)
+++ trunk/boost/asio/windows/basic_stream_handle.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -21,10 +21,11 @@
   || defined(GENERATING_DOCUMENTATION)
 
 #include <cstddef>
+#include <boost/asio/detail/handler_type_requirements.hpp>
+#include <boost/asio/detail/throw_error.hpp>
 #include <boost/asio/error.hpp>
 #include <boost/asio/windows/basic_handle.hpp>
 #include <boost/asio/windows/stream_handle_service.hpp>
-#include <boost/asio/detail/throw_error.hpp>
 
 #include <boost/asio/detail/push_options.hpp>
 
@@ -49,8 +50,12 @@
   : public basic_handle<StreamHandleService>
 {
 public:
+ /// (Deprecated: Use native_handle_type.) The native representation of a
+ /// handle.
+ typedef typename StreamHandleService::native_handle_type native_type;
+
   /// The native representation of a handle.
- typedef typename StreamHandleService::native_type native_type;
+ typedef typename StreamHandleService::native_handle_type native_handle_type;
 
   /// Construct a basic_stream_handle without opening it.
   /**
@@ -74,13 +79,13 @@
    * @param io_service The io_service object that the stream handle will use to
    * dispatch handlers for any asynchronous operations performed on the handle.
    *
- * @param native_handle The new underlying handle implementation.
+ * @param handle The new underlying handle implementation.
    *
    * @throws boost::system::system_error Thrown on failure.
    */
   basic_stream_handle(boost::asio::io_service& io_service,
- const native_type& native_handle)
- : basic_handle<StreamHandleService>(io_service, native_handle)
+ const native_handle_type& handle)
+ : basic_handle<StreamHandleService>(io_service, handle)
   {
   }
 
@@ -182,7 +187,12 @@
   void async_write_some(const ConstBufferSequence& buffers,
       WriteHandler handler)
   {
- this->service.async_write_some(this->implementation, buffers, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a WriteHandler.
+ BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
+
+ this->service.async_write_some(this->implementation, buffers,
+ BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
   /// Read some data from the handle.
@@ -286,7 +296,12 @@
   void async_read_some(const MutableBufferSequence& buffers,
       ReadHandler handler)
   {
- this->service.async_read_some(this->implementation, buffers, handler);
+ // If you get an error on the following line it means that your handler does
+ // not meet the documented type requirements for a ReadHandler.
+ BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
+
+ this->service.async_read_some(this->implementation, buffers,
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 };
 

Modified: trunk/boost/asio/windows/random_access_handle_service.hpp
==============================================================================
--- trunk/boost/asio/windows/random_access_handle_service.hpp (original)
+++ trunk/boost/asio/windows/random_access_handle_service.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -59,11 +59,18 @@
   typedef service_impl_type::implementation_type implementation_type;
 #endif
 
- /// The native handle type.
+ /// (Deprecated: Use native_handle_type.) The native handle type.
 #if defined(GENERATING_DOCUMENTATION)
   typedef implementation_defined native_type;
 #else
- typedef service_impl_type::native_type native_type;
+ typedef service_impl_type::native_handle_type native_type;
+#endif
+
+ /// The native handle type.
+#if defined(GENERATING_DOCUMENTATION)
+ typedef implementation_defined native_handle_type;
+#else
+ typedef service_impl_type::native_handle_type native_handle_type;
 #endif
 
   /// Construct a new random-access handle service for the specified io_service.
@@ -94,9 +101,9 @@
 
   /// Assign an existing native handle to a random-access handle.
   boost::system::error_code assign(implementation_type& impl,
- const native_type& native_handle, boost::system::error_code& ec)
+ const native_handle_type& handle, boost::system::error_code& ec)
   {
- return service_impl_.assign(impl, native_handle, ec);
+ return service_impl_.assign(impl, handle, ec);
   }
 
   /// Determine whether the handle is open.
@@ -112,10 +119,16 @@
     return service_impl_.close(impl, ec);
   }
 
- /// Get the native handle implementation.
+ /// (Deprecated: Use native_handle().) Get the native handle implementation.
   native_type native(implementation_type& impl)
   {
- return service_impl_.native(impl);
+ return service_impl_.native_handle(impl);
+ }
+
+ /// Get the native handle implementation.
+ native_handle_type native_handle(implementation_type& impl)
+ {
+ return service_impl_.native_handle(impl);
   }
 
   /// Cancel all asynchronous operations associated with the handle.

Modified: trunk/boost/asio/windows/stream_handle_service.hpp
==============================================================================
--- trunk/boost/asio/windows/stream_handle_service.hpp (original)
+++ trunk/boost/asio/windows/stream_handle_service.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -57,11 +57,18 @@
   typedef service_impl_type::implementation_type implementation_type;
 #endif
 
- /// The native handle type.
+ /// (Deprecated: Use native_handle_type.) The native handle type.
 #if defined(GENERATING_DOCUMENTATION)
   typedef implementation_defined native_type;
 #else
- typedef service_impl_type::native_type native_type;
+ typedef service_impl_type::native_handle_type native_type;
+#endif
+
+ /// The native handle type.
+#if defined(GENERATING_DOCUMENTATION)
+ typedef implementation_defined native_handle_type;
+#else
+ typedef service_impl_type::native_handle_type native_handle_type;
 #endif
 
   /// Construct a new stream handle service for the specified io_service.
@@ -91,9 +98,9 @@
 
   /// Assign an existing native handle to a stream handle.
   boost::system::error_code assign(implementation_type& impl,
- const native_type& native_handle, boost::system::error_code& ec)
+ const native_handle_type& handle, boost::system::error_code& ec)
   {
- return service_impl_.assign(impl, native_handle, ec);
+ return service_impl_.assign(impl, handle, ec);
   }
 
   /// Determine whether the handle is open.
@@ -109,10 +116,16 @@
     return service_impl_.close(impl, ec);
   }
 
- /// Get the native handle implementation.
+ /// (Deprecated: Use native_handle().) Get the native handle implementation.
   native_type native(implementation_type& impl)
   {
- return service_impl_.native(impl);
+ return service_impl_.native_handle(impl);
+ }
+
+ /// Get the native handle implementation.
+ native_handle_type native_handle(implementation_type& impl)
+ {
+ return service_impl_.native_handle(impl);
   }
 
   /// Cancel all asynchronous operations associated with the handle.

Modified: trunk/boost/asio/write.hpp
==============================================================================
--- trunk/boost/asio/write.hpp (original)
+++ trunk/boost/asio/write.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -71,6 +71,46 @@
 template <typename SyncWriteStream, typename ConstBufferSequence>
 std::size_t write(SyncWriteStream& s, const ConstBufferSequence& buffers);
 
+/// Write all of the supplied data to a stream before returning.
+/**
+ * This function is used to write a certain number of bytes of data to a stream.
+ * The call will block until one of the following conditions is true:
+ *
+ * @li All of the data in the supplied buffers has been written. That is, the
+ * bytes transferred is equal to the sum of the buffer sizes.
+ *
+ * @li An error occurred.
+ *
+ * This operation is implemented in terms of zero or more calls to the stream's
+ * write_some function.
+ *
+ * @param s The stream to which the data is to be written. The type must support
+ * the SyncWriteStream concept.
+ *
+ * @param buffers One or more buffers containing the data to be written. The sum
+ * of the buffer sizes indicates the maximum number of bytes to write to the
+ * stream.
+ *
+ * @param ec Set to indicate what error occurred, if any.
+ *
+ * @returns The number of bytes transferred.
+ *
+ * @par Example
+ * To write a single data buffer use the @ref buffer function as follows:
+ * @code boost::asio::write(s, boost::asio::buffer(data, size), ec); @endcode
+ * See the @ref buffer documentation for information on writing multiple
+ * buffers in one go, and how to use it with arrays, boost::array or
+ * std::vector.
+ *
+ * @note This overload is equivalent to calling:
+ * @code boost::asio::write(
+ * s, buffers,
+ * boost::asio::transfer_all(), ec); @endcode
+ */
+template <typename SyncWriteStream, typename ConstBufferSequence>
+std::size_t write(SyncWriteStream& s, const ConstBufferSequence& buffers,
+ boost::system::error_code& ec);
+
 /// Write a certain amount of data to a stream before returning.
 /**
  * This function is used to write a certain number of bytes of data to a stream.
@@ -197,6 +237,36 @@
 template <typename SyncWriteStream, typename Allocator>
 std::size_t write(SyncWriteStream& s, basic_streambuf<Allocator>& b);
 
+/// Write all of the supplied data to a stream before returning.
+/**
+ * This function is used to write a certain number of bytes of data to a stream.
+ * The call will block until one of the following conditions is true:
+ *
+ * @li All of the data in the supplied basic_streambuf has been written.
+ *
+ * @li An error occurred.
+ *
+ * This operation is implemented in terms of zero or more calls to the stream's
+ * write_some function.
+ *
+ * @param s The stream to which the data is to be written. The type must support
+ * the SyncWriteStream concept.
+ *
+ * @param b The basic_streambuf object from which data will be written.
+ *
+ * @param ec Set to indicate what error occurred, if any.
+ *
+ * @returns The number of bytes transferred.
+ *
+ * @note This overload is equivalent to calling:
+ * @code boost::asio::write(
+ * s, b,
+ * boost::asio::transfer_all(), ec); @endcode
+ */
+template <typename SyncWriteStream, typename Allocator>
+std::size_t write(SyncWriteStream& s, basic_streambuf<Allocator>& b,
+ boost::system::error_code& ec);
+
 /// Write a certain amount of data to a stream before returning.
 /**
  * This function is used to write a certain number of bytes of data to a stream.

Modified: trunk/boost/asio/write_at.hpp
==============================================================================
--- trunk/boost/asio/write_at.hpp (original)
+++ trunk/boost/asio/write_at.hpp 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -76,6 +76,51 @@
 std::size_t write_at(SyncRandomAccessWriteDevice& d,
     boost::uint64_t offset, const ConstBufferSequence& buffers);
 
+/// Write all of the supplied data at the specified offset before returning.
+/**
+ * This function is used to write a certain number of bytes of data to a random
+ * access device at a specified offset. The call will block until one of the
+ * following conditions is true:
+ *
+ * @li All of the data in the supplied buffers has been written. That is, the
+ * bytes transferred is equal to the sum of the buffer sizes.
+ *
+ * @li An error occurred.
+ *
+ * This operation is implemented in terms of zero or more calls to the device's
+ * write_some_at function.
+ *
+ * @param d The device to which the data is to be written. The type must support
+ * the SyncRandomAccessWriteDevice concept.
+ *
+ * @param offset The offset at which the data will be written.
+ *
+ * @param buffers One or more buffers containing the data to be written. The sum
+ * of the buffer sizes indicates the maximum number of bytes to write to the
+ * device.
+ *
+ * @param ec Set to indicate what error occurred, if any.
+ *
+ * @returns The number of bytes transferred.
+ *
+ * @par Example
+ * To write a single data buffer use the @ref buffer function as follows:
+ * @code boost::asio::write_at(d, 42,
+ * boost::asio::buffer(data, size), ec); @endcode
+ * See the @ref buffer documentation for information on writing multiple
+ * buffers in one go, and how to use it with arrays, boost::array or
+ * std::vector.
+ *
+ * @note This overload is equivalent to calling:
+ * @code boost::asio::write_at(
+ * d, offset, buffers,
+ * boost::asio::transfer_all(), ec); @endcode
+ */
+template <typename SyncRandomAccessWriteDevice, typename ConstBufferSequence>
+std::size_t write_at(SyncRandomAccessWriteDevice& d,
+ boost::uint64_t offset, const ConstBufferSequence& buffers,
+ boost::system::error_code& ec);
+
 /// Write a certain amount of data at a specified offset before returning.
 /**
  * This function is used to write a certain number of bytes of data to a random
@@ -214,6 +259,40 @@
 std::size_t write_at(SyncRandomAccessWriteDevice& d,
     boost::uint64_t offset, basic_streambuf<Allocator>& b);
 
+/// Write all of the supplied data at the specified offset before returning.
+/**
+ * This function is used to write a certain number of bytes of data to a random
+ * access device at a specified offset. The call will block until one of the
+ * following conditions is true:
+ *
+ * @li All of the data in the supplied basic_streambuf has been written.
+ *
+ * @li An error occurred.
+ *
+ * This operation is implemented in terms of zero or more calls to the device's
+ * write_some_at function.
+ *
+ * @param d The device to which the data is to be written. The type must support
+ * the SyncRandomAccessWriteDevice concept.
+ *
+ * @param offset The offset at which the data will be written.
+ *
+ * @param b The basic_streambuf object from which data will be written.
+ *
+ * @param ec Set to indicate what error occurred, if any.
+ *
+ * @returns The number of bytes transferred.
+ *
+ * @note This overload is equivalent to calling:
+ * @code boost::asio::write_at(
+ * d, 42, b,
+ * boost::asio::transfer_all(), ec); @endcode
+ */
+template <typename SyncRandomAccessWriteDevice, typename Allocator>
+std::size_t write_at(SyncRandomAccessWriteDevice& d,
+ boost::uint64_t offset, basic_streambuf<Allocator>& b,
+ boost::system::error_code& ec);
+
 /// Write a certain amount of data at a specified offset before returning.
 /**
  * This function is used to write a certain number of bytes of data to a random

Modified: trunk/libs/asio/doc/asio.qbk
==============================================================================
--- trunk/libs/asio/doc/asio.qbk (original)
+++ trunk/libs/asio/doc/asio.qbk 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -7,7 +7,7 @@
 
 [library Boost.Asio
     [quickbook 1.4]
- [copyright 2003 - 2010 Christopher M. Kohlhoff]
+ [copyright 2003 - 2011 Christopher M. Kohlhoff]
     [purpose Networking library]
     [license
         Distributed under the Boost Software License, Version 1.0.
@@ -37,9 +37,9 @@
 
 [/=============================================================================]
 
-Boost.Asio is a cross-platform C++ library for network and low-level I/O
-programming that provides developers with a consistent asynchronous model using
-a modern C++ approach.
+Boost.Asio is a cross-platform C++ library for network and low-level I/O programming
+that provides developers with a consistent asynchronous model using a modern
+C++ approach.
 
 [variablelist
   [
@@ -74,8 +74,7 @@
       [link boost_asio.examples Examples]
     ]
     [
- Examples that illustrate the use of Boost.Asio in more complex
- applications.
+ Examples that illustrate the use of Boost.Asio in more complex applications.
     ]
   ]
   [

Modified: trunk/libs/asio/doc/examples.qbk
==============================================================================
--- trunk/libs/asio/doc/examples.qbk (original)
+++ trunk/libs/asio/doc/examples.qbk 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -34,8 +34,8 @@
 * [@boost_asio/example/chat/chat_server.cpp]
 
 The following POSIX-specific chat client demonstrates how to use the
-[link boost_asio.reference.posix__stream_descriptor posix::stream_descriptor]
-class to perform console input and output.
+[link boost_asio.reference.posix__stream_descriptor posix::stream_descriptor] class to
+perform console input and output.
 
 * [@boost_asio/example/chat/posix_chat_client.cpp]
 
@@ -182,6 +182,7 @@
 
 * [@boost_asio/example/iostreams/daytime_client.cpp]
 * [@boost_asio/example/iostreams/daytime_server.cpp]
+* [@boost_asio/example/iostreams/http_client.cpp]
 
 
 [heading Multicast]
@@ -231,8 +232,7 @@
 [heading SSL]
 
 Example client and server programs showing the use of the [link
-boost_asio.reference.ssl__stream ssl::stream<>] template with asynchronous
-operations.
+boost_asio.reference.ssl__stream ssl::stream<>] template with asynchronous operations.
 
 * [@boost_asio/example/ssl/client.cpp]
 * [@boost_asio/example/ssl/server.cpp]

Modified: trunk/libs/asio/doc/overview/basics.qbk
==============================================================================
--- trunk/libs/asio/doc/overview/basics.qbk (original)
+++ trunk/libs/asio/doc/overview/basics.qbk 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -43,13 +43,13 @@
 4. The [*operating system] returns the result of the operation to the
 [*io_service].
 
-5. The [*io_service] translates any error resulting from the operation into a
-`boost::system::error_code`. An `error_code` may be compared with specific
-values, or tested as a boolean (where a `false` result means that no error
-occurred). The result is then forwarded back up to the [*I/O object].
+5. The [*io_service] translates any error resulting from the operation into an
+object of type `boost::system::error_code`. An `error_code` may be compared with
+specific values, or tested as a boolean (where a `false` result means that no
+error occurred). The result is then forwarded back up to the [*I/O object].
 
-6. The [*I/O object] throws an exception of type `boost::system::system_error`
-if the operation failed. If the code to initiate the operation had instead been
+6. The [*I/O object] throws an exception of type `boost::system::system_error` if the
+operation failed. If the code to initiate the operation had instead been
 written as:
 
   boost::system::error_code ec;

Modified: trunk/libs/asio/doc/overview/implementation.qbk
==============================================================================
--- trunk/libs/asio/doc/overview/implementation.qbk (original)
+++ trunk/libs/asio/doc/overview/implementation.qbk 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -241,6 +241,10 @@
 `io_service::run()`, `io_service::run_one()`, `io_service::poll()` or
 `io_service::poll_one()`.
 
+* An additional thread per `io_service` is used to trigger timers. This thread
+is created on construction of the first `deadline_timer` or
+`deadline_timer_service` objects.
+
 * An additional thread per `io_service` is used for the `select`
 demultiplexing. This thread is created on the first call to `async_connect()`.
 

Modified: trunk/libs/asio/doc/overview/serial_ports.qbk
==============================================================================
--- trunk/libs/asio/doc/overview/serial_ports.qbk (original)
+++ trunk/libs/asio/doc/overview/serial_ports.qbk 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -15,12 +15,11 @@
 where name is something like `"COM1"` on Windows, and `"/dev/ttyS0"` on POSIX
 platforms.
 
-Once opened, the serial port may be used as a [link
-boost_asio.overview.core.streams stream]. This means the objects can be used
-with any of the [link boost_asio.reference.read read()], [link
-boost_asio.reference.async_read async_read()], [link boost_asio.reference.write
-write()], [link boost_asio.reference.async_write async_write()], [link
-boost_asio.reference.read_until read_until()] or [link
+Once opened, the serial port may be used as a [link boost_asio.overview.core.streams
+stream]. This means the objects can be used with any of the [link
+boost_asio.reference.read read()], [link boost_asio.reference.async_read async_read()],
+[link boost_asio.reference.write write()], [link boost_asio.reference.async_write
+async_write()], [link boost_asio.reference.read_until read_until()] or [link
 boost_asio.reference.async_read_until async_read_until()] free functions.
 
 The serial port implementation also includes option classes for configuring the

Modified: trunk/libs/asio/doc/overview/ssl.qbk
==============================================================================
--- trunk/libs/asio/doc/overview/ssl.qbk (original)
+++ trunk/libs/asio/doc/overview/ssl.qbk 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -41,9 +41,8 @@
 
 SSL handshaking must be performed prior to transmitting or receiving data over
 an encrypted connection. This is accomplished using the `ssl::stream`
-template's [link boost_asio.reference.ssl__stream.handshake handshake()] or
-[link boost_asio.reference.ssl__stream.async_handshake async_handshake()] member
-functions.
+template's [link boost_asio.reference.ssl__stream.handshake handshake()] or [link
+boost_asio.reference.ssl__stream.async_handshake async_handshake()] member functions.
 
 Once connected, SSL stream objects are used as synchronous or asynchronous read
 and write streams. This means the objects can be used with any of the [link

Modified: trunk/libs/asio/doc/quickref.xml
==============================================================================
--- trunk/libs/asio/doc/quickref.xml (original)
+++ trunk/libs/asio/doc/quickref.xml 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -63,6 +63,9 @@
             <member><link linkend="boost_asio.reference.async_write">async_write</link></member>
             <member><link linkend="boost_asio.reference.async_write_at">async_write_at</link></member>
             <member><link linkend="boost_asio.reference.buffer">buffer</link></member>
+ <member><link linkend="boost_asio.reference.buffer_cast">buffer_cast</link></member>
+ <member><link linkend="boost_asio.reference.buffer_copy">buffer_copy</link></member>
+ <member><link linkend="boost_asio.reference.buffer_size">buffer_size</link></member>
             <member><link linkend="boost_asio.reference.buffers_begin">buffers_begin</link></member>
             <member><link linkend="boost_asio.reference.buffers_end">buffers_end</link></member>
             <member><link linkend="boost_asio.reference.has_service">has_service</link></member>
@@ -71,6 +74,7 @@
             <member><link linkend="boost_asio.reference.read_until">read_until</link></member>
             <member><link linkend="boost_asio.reference.transfer_all">transfer_all</link></member>
             <member><link linkend="boost_asio.reference.transfer_at_least">transfer_at_least</link></member>
+ <member><link linkend="boost_asio.reference.transfer_exactly">transfer_exactly</link></member>
             <member><link linkend="boost_asio.reference.use_service">use_service</link></member>
             <member><link linkend="boost_asio.reference.write">write</link></member>
             <member><link linkend="boost_asio.reference.write_at">write_at</link></member>
@@ -163,6 +167,8 @@
           </simplelist>
           <bridgehead renderas="sect3">Free Functions</bridgehead>
           <simplelist type="vert" columns="1">
+ <member><link linkend="boost_asio.reference.async_connect">async_connect</link></member>
+ <member><link linkend="boost_asio.reference.connect">connect</link></member>
             <member><link linkend="boost_asio.reference.ip__host_name">ip::host_name</link></member>
           </simplelist>
         </entry>
@@ -171,8 +177,9 @@
           <simplelist type="vert" columns="1">
             <member><link linkend="boost_asio.reference.basic_datagram_socket">basic_datagram_socket</link></member>
             <member><link linkend="boost_asio.reference.basic_deadline_timer">basic_deadline_timer</link></member>
- <member><link linkend="boost_asio.reference.basic_socket">basic_socket</link></member>
             <member><link linkend="boost_asio.reference.basic_raw_socket">basic_raw_socket</link></member>
+ <member><link linkend="boost_asio.reference.basic_seq_packet_socket">basic_seq_packet_socket</link></member>
+ <member><link linkend="boost_asio.reference.basic_socket">basic_socket</link></member>
             <member><link linkend="boost_asio.reference.basic_socket_acceptor">basic_socket_acceptor</link></member>
             <member><link linkend="boost_asio.reference.basic_socket_iostream">basic_socket_iostream</link></member>
             <member><link linkend="boost_asio.reference.basic_socket_streambuf">basic_socket_streambuf</link></member>
@@ -188,6 +195,7 @@
             <member><link linkend="boost_asio.reference.datagram_socket_service">datagram_socket_service</link></member>
             <member><link linkend="boost_asio.reference.ip__resolver_service">ip::resolver_service</link></member>
             <member><link linkend="boost_asio.reference.raw_socket_service">raw_socket_service</link></member>
+ <member><link linkend="boost_asio.reference.seq_packet_socket_service">seq_packet_socket_service</link></member>
             <member><link linkend="boost_asio.reference.socket_acceptor_service">socket_acceptor_service</link></member>
             <member><link linkend="boost_asio.reference.stream_socket_service">stream_socket_service</link></member>
           </simplelist>
@@ -225,6 +233,7 @@
           <bridgehead renderas="sect3">Type Requirements</bridgehead>
           <simplelist type="vert" columns="1">
             <member><link linkend="boost_asio.reference.AcceptHandler">AcceptHandler</link></member>
+ <member><link linkend="boost_asio.reference.ComposedConnectHandler">ComposedConnectHandler</link></member>
             <member><link linkend="boost_asio.reference.ConnectHandler">ConnectHandler</link></member>
             <member><link linkend="boost_asio.reference.DatagramSocketService">DatagramSocketService</link></member>
             <member><link linkend="boost_asio.reference.Endpoint">Endpoint</link></member>
@@ -235,6 +244,7 @@
             <member><link linkend="boost_asio.reference.RawSocketService">RawSocketService</link></member>
             <member><link linkend="boost_asio.reference.ResolveHandler">ResolveHandler</link></member>
             <member><link linkend="boost_asio.reference.ResolverService">ResolverService</link></member>
+ <member><link linkend="boost_asio.reference.SeqPacketSocketService">SeqPacketSocketService</link></member>
             <member><link linkend="boost_asio.reference.SettableSocketOption">SettableSocketOption</link></member>
             <member><link linkend="boost_asio.reference.SocketAcceptorService">SocketAcceptorService</link></member>
             <member><link linkend="boost_asio.reference.SocketService">SocketService</link></member>

Modified: trunk/libs/asio/doc/reference.qbk
==============================================================================
--- trunk/libs/asio/doc/reference.qbk (original)
+++ trunk/libs/asio/doc/reference.qbk 2011-02-22 20:04:16 EST (Tue, 22 Feb 2011)
@@ -16,6 +16,7 @@
 [include requirements/AsyncReadStream.qbk]
 [include requirements/AsyncWriteStream.qbk]
 [include requirements/CompletionHandler.qbk]
+[include requirements/ComposedConnectHandler.qbk]
 [include requirements/ConnectHandler.qbk]
 [include requirements/ConstBufferSequence.qbk]
 [include requirements/ConvertibleToConstBuffer.qbk]
@@ -37,6 +38,7 @@
 [include requirements/ReadHandler.qbk]
 [include requirements/ResolveHandler.qbk]
 [include requirements/ResolverService.qbk]
+[include requirements/SeqPacketSocketService.qbk]
 [include requirements/SerialPortService.qbk]
 [include requirements/Service.qbk]
 [include requirements/SettableSerialPortOption.qbk]
@@ -261,6 +263,518 @@
 [endsect]
 
 
+[section:async_connect async_connect]
+
+[indexterm1 async_connect]
+Asynchronously establishes a socket connection by trying each endpoint in a sequence.
+
+
+ template<
+ typename ``[link boost_asio.reference.Protocol Protocol]``,
+ typename ``[link boost_asio.reference.SocketService SocketService]``,
+ typename Iterator,
+ typename ``[link boost_asio.reference.ComposedConnectHandler ComposedConnectHandler]``>
+ void ``[link boost_asio.reference.async_connect.overload1 async_connect]``(
+ basic_socket< Protocol, SocketService > & s,
+ Iterator begin,
+ ComposedConnectHandler handler);
+ `` [''''&raquo;''' [link boost_asio.reference.async_connect.overload1 more...]]``
+
+ template<
+ typename ``[link boost_asio.reference.Protocol Protocol]``,
+ typename ``[link boost_asio.reference.SocketService SocketService]``,
+ typename Iterator,
+ typename ``[link boost_asio.reference.ComposedConnectHandler ComposedConnectHandler]``>
+ void ``[link boost_asio.reference.async_connect.overload2 async_connect]``(
+ basic_socket< Protocol, SocketService > & s,
+ Iterator begin,
+ Iterator end,
+ ComposedConnectHandler handler);
+ `` [''''&raquo;''' [link boost_asio.reference.async_connect.overload2 more...]]``
+
+ template<
+ typename ``[link boost_asio.reference.Protocol Protocol]``,
+ typename ``[link boost_asio.reference.SocketService SocketService]``,
+ typename Iterator,
+ typename ConnectCondition,
+ typename ``[link boost_asio.reference.ComposedConnectHandler ComposedConnectHandler]``>
+ void ``[link boost_asio.reference.async_connect.overload3 async_connect]``(
+ basic_socket< Protocol, SocketService > & s,
+ Iterator begin,
+ ConnectCondition connect_condition,
+ ComposedConnectHandler handler);
+ `` [''''&raquo;''' [link boost_asio.reference.async_connect.overload3 more...]]``
+
+ template<
+ typename ``[link boost_asio.reference.Protocol Protocol]``,
+ typename ``[link boost_asio.reference.SocketService SocketService]``,
+ typename Iterator,
+ typename ConnectCondition,
+ typename ``[link boost_asio.reference.ComposedConnectHandler ComposedConnectHandler]``>
+ void ``[link boost_asio.reference.async_connect.overload4 async_connect]``(
+ basic_socket< Protocol, SocketService > & s,
+ Iterator begin,
+ Iterator end,
+ ConnectCondition connect_condition,
+ ComposedConnectHandler handler);
+ `` [''''&raquo;''' [link boost_asio.reference.async_connect.overload4 more...]]``
+
+[heading Requirements]
+
+[*Header: ][^boost/asio/connect.hpp]
+
+[*Convenience header: ][^boost/asio.hpp]
+
+
+[section:overload1 async_connect (1 of 4 overloads)]
+
+
+Asynchronously establishes a socket connection by trying each endpoint in a sequence.
+
+
+ template<
+ typename ``[link boost_asio.reference.Protocol Protocol]``,
+ typename ``[link boost_asio.reference.SocketService SocketService]``,
+ typename Iterator,
+ typename ``[link boost_asio.reference.ComposedConnectHandler ComposedConnectHandler]``>
+ void async_connect(
+ basic_socket< Protocol, SocketService > & s,
+ Iterator begin,
+ ComposedConnectHandler handler);
+
+
+This function attempts to connect a socket to one of a sequence of endpoints. It does this by repeated calls to the socket's `async_connect` member function, once for each endpoint in the sequence, until a connection is successfully established.
+
+
+[heading Parameters]
+
+
+[variablelist
+
+[[s][The socket to be connected. If the socket is already open, it will be closed.]]
+
+[[begin][An iterator pointing to the start of a sequence of endpoints.]]
+
+[[handler][The handler to be called when the connect operation completes. Copies will be made of the handler as required. The function signature of the handler must be:
+``
+ void handler(
+ // Result of operation. if the sequence is empty, set to
+ // boost::asio::error::not_found. Otherwise, contains the
+ // error from the last connection attempt.
+ const boost::system::error_code& error,
+
+ // On success, an iterator denoting the successfully
+ // connected endpoint. Otherwise, the end iterator.
+ Iterator iterator
+ );
+``
+Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using `boost::asio::io_service::post()`.]]
+
+]
+
+
+[heading Remarks]
+
+This overload assumes that a default constructed object of type `Iterator` represents the end of the sequence. This is a valid assumption for iterator types such as `boost::asio::ip::tcp::resolver::iterator`.
+
+
+[heading Example]
+
+
+
+ tcp::resolver r(io_service);
+ tcp::resolver::query q("host", "service");
+ tcp::socket s(io_service);
+
+ // ...
+
+ r.async_resolve(q, resolve_handler);
+
+ // ...
+
+ void resolve_handler(
+ const boost::system::error_code& ec,
+ tcp::resolver::iterator i)
+ {
+ if (!ec)
+ {
+ boost::asio::async_connect(s, i, connect_handler);
+ }
+ }
+
+ // ...
+
+ void connect_handler(
+ const boost::system::error_code& ec,
+ tcp::resolver::iterator i)
+ {
+ // ...
+ }
+
+
+
+
+
+
+
+[endsect]
+
+
+
+[section:overload2 async_connect (2 of 4 overloads)]
+
+
+Asynchronously establishes a socket connection by trying each endpoint in a sequence.
+
+
+ template<
+ typename ``[link boost_asio.reference.Protocol Protocol]``,
+ typename ``[link boost_asio.reference.SocketService SocketService]``,
+ typename Iterator,
+ typename ``[link boost_asio.reference.ComposedConnectHandler ComposedConnectHandler]``>
+ void async_connect(
+ basic_socket< Protocol, SocketService > & s,
+ Iterator begin,
+ Iterator end,
+ ComposedConnectHandler handler);
+
+
+This function attempts to connect a socket to one of a sequence of endpoints. It does this by repeated calls to the socket's `async_connect` member function, once for each endpoint in the sequence, until a connection is successfully established.
+
+
+[heading Parameters]
+
+
+[variablelist
+
+[[s][The socket to be connected. If the socket is already open, it will be closed.]]
+
+[[begin][An iterator pointing to the start of a sequence of endpoints.]]
+
+[[end][An iterator pointing to the end of a sequence of endpoints.]]
+
+[[handler][The handler to be called when the connect operation completes. Copies will be made of the handler as required. The function signature of the handler must be:
+``
+ void handler(
+ // Result of operation. if the sequence is empty, set to
+ // boost::asio::error::not_found. Otherwise, contains the
+ // error from the last connection attempt.
+ const boost::system::error_code& error,
+
+ // On success, an iterator denoting the successfully
+ // connected endpoint. Otherwise, the end iterator.
+ Iterator iterator
+ );
+``
+Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using `boost::asio::io_service::post()`.]]
+
+]
+
+
+[heading Example]
+
+
+
+ tcp::resolver r(io_service);
+ tcp::resolver::query q("host", "service");
+ tcp::socket s(io_service);
+
+ // ...
+
+ r.async_resolve(q, resolve_handler);
+
+ // ...
+
+ void resolve_handler(
+ const boost::system::error_code& ec,
+ tcp::resolver::iterator i)
+ {
+ if (!ec)
+ {
+ tcp::resolver::iterator end;
+ boost::asio::async_connect(s, i, end, connect_handler);
+ }
+ }
+
+ // ...
+
+ void connect_handler(
+ const boost::system::error_code& ec,
+ tcp::resolver::iterator i)
+ {
+ // ...
+ }
+
+
+
+
+
+
+
+[endsect]
+
+
+
+[section:overload3 async_connect (3 of 4 overloads)]
+
+
+Asynchronously establishes a socket connection by trying each endpoint in a sequence.
+
+
+ template<
+ typename ``[link boost_asio.reference.Protocol Protocol]``,
+ typename ``[link boost_asio.reference.SocketService SocketService]``,
+ typename Iterator,
+ typename ConnectCondition,
+ typename ``[link boost_asio.reference.ComposedConnectHandler ComposedConnectHandler]``>
+ void async_connect(
+ basic_socket< Protocol, SocketService > & s,
+ Iterator begin,
+ ConnectCondition connect_condition,
+ ComposedConnectHandler handler);
+
+
+This function attempts to connect a socket to one of a sequence of endpoints. It does this by repeated calls to the socket's `async_connect` member function, once for each endpoint in the sequence, until a connection is successfully established.
+
+
+[heading Parameters]
+
+
+[variablelist
+
+[[s][The socket to be connected. If the socket is already open, it will be closed.]]
+
+[[begin][An iterator pointing to the start of a sequence of endpoints.]]
+
+[[connect_condition][A function object that is called prior to each connection attempt. The signature of the function object must be:
+``
+ Iterator connect_condition(
+ const boost::system::error_code& ec,
+ Iterator next);
+``
+The `ec` parameter contains the result from the most recent connect operation. Before the first connection attempt, `ec` is always set to indicate success. The `next` parameter is an iterator pointing to the next endpoint to be tried. The function object should return the next iterator, but is permitted to return a different iterator so that endpoints may be skipped. The implementation guarantees that the function object will never be called with the end iterator.]]
+
+[[handler][The handler to be called when the connect operation completes. Copies will be made of the handler as required. The function signature of the handler must be:
+``
+ void handler(
+ // Result of operation. if the sequence is empty, set to
+ // boost::asio::error::not_found. Otherwise, contains the
+ // error from the last connection attempt.
+ const boost::system::error_code& error,
+
+ // On success, an iterator denoting the successfully
+ // connected endpoint. Otherwise, the end iterator.
+ Iterator iterator
+ );
+``
+Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using `boost::asio::io_service::post()`.]]
+
+]
+
+
+[heading Remarks]
+
+This overload assumes that a default constructed object of type `Iterator` represents the end of the sequence. This is a valid assumption for iterator types such as `boost::asio::ip::tcp::resolver::iterator`.
+
+
+[heading Example]
+
+The following connect condition function object can be used to output information about the individual connection attempts:
+
+ struct my_connect_condition
+ {
+ template <typename Iterator>
+ Iterator operator()(
+ const boost::system::error_code& ec,
+ Iterator next)
+ {
+ if (ec) std::cout << "Error: " << ec.message() << std::endl;
+ std::cout << "Trying: " << next->endpoint() << std::endl;
+ return next;
+ }
+ };
+
+
+It would be used with the `boost::asio::connect` function as follows:
+
+ tcp::resolver r(io_service);
+ tcp::resolver::query q("host", "service");
+ tcp::socket s(io_service);
+
+ // ...
+
+ r.async_resolve(q, resolve_handler);
+
+ // ...
+
+ void resolve_handler(
+ const boost::system::error_code& ec,
+ tcp::resolver::iterator i)
+ {
+ if (!ec)
+ {
+ boost::asio::async_connect(s, i,
+ my_connect_condition(),
+ connect_handler);
+ }
+ }
+
+ // ...
+
+ void connect_handler(
+ const boost::system::error_code& ec,
+ tcp::resolver::iterator i)
+ {
+ if (ec)
+ {
+ // An error occurred.
+ }
+ else
+ {
+ std::cout << "Connected to: " << i->endpoint() << std::endl;
+ }
+ }
+
+
+
+
+
+
+
+[endsect]
+
+
+
+[section:overload4 async_connect (4 of 4 overloads)]
+
+
+Asynchronously establishes a socket connection by trying each endpoint in a sequence.
+
+
+ template<
+ typename ``[link boost_asio.reference.Protocol Protocol]``,
+ typename ``[link boost_asio.reference.SocketService SocketService]``,
+ typename Iterator,
+ typename ConnectCondition,
+ typename ``[link boost_asio.reference.ComposedConnectHandler ComposedConnectHandler]``>
+ void async_connect(
+ basic_socket< Protocol, SocketService > & s,
+ Iterator begin,
+ Iterator end,
+ ConnectCondition connect_condition,
+ ComposedConnectHandler handler);
+
+
+This function attempts to connect a socket to one of a sequence of endpoints. It does this by repeated calls to the socket's `async_connect` member function, once for each endpoint in the sequence, until a connection is successfully established.
+
+
+[heading Parameters]
+
+
+[variablelist
+
+[[s][The socket to be connected. If the socket is already open, it will be closed.]]
+
+[[begin][An iterator pointing to the start of a sequence of endpoints.]]
+
+[[end][An iterator pointing to the end of a sequence of endpoints.]]
+
+[[connect_condition][A function object that is called prior to each connection attempt. The signature of the function object must be:
+``
+ Iterator connect_condition(
+ const boost::system::error_code& ec,
+ Iterator next);
+``
+The `ec` parameter contains the result from the most recent connect operation. Before the first connection attempt, `ec` is always set to indicate success. The `next` parameter is an iterator pointing to the next endpoint to be tried. The function object should return the next iterator, but is permitted to return a different iterator so that endpoints may be skipped. The implementation guarantees that the function object will never be called with the end iterator.]]
+
+[[handler][The handler to be called when the connect operation completes. Copies will be made of the handler as required. The function signature of the handler must be:
+``
+ void handler(
+ // Result of operation. if the sequence is empty, set to
+ // boost::asio::error::not_found. Otherwise, contains the
+ // error from the last connection attempt.
+ const boost::system::error_code& error,
+
+ // On success, an iterator denoting the successfully
+ // connected endpoint. Otherwise, the end iterator.
+ Iterator iterator
+ );
+``
+Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using `boost::asio::io_service::post()`.]]
+
+]
+
+
+[heading Example]
+
+The following connect condition function object can be used to output information about the individual connection attempts:
+
+ struct my_connect_condition
+ {
+ template <typename Iterator>
+ Iterator operator()(
+ const boost::system::error_code& ec,
+ Iterator next)
+ {
+ if (ec) std::cout << "Error: " << ec.message() << std::endl;
+ std::cout << "Trying: " << next->endpoint() << std::endl;
+ return next;
+ }
+ };
+
+
+It would be used with the `boost::asio::connect` function as follows:
+
+ tcp::resolver r(io_service);
+ tcp::resolver::query q("host", "service");
+ tcp::socket s(io_service);
+
+ // ...
+
+ r.async_resolve(q, resolve_handler);
+
+ // ...
+
+ void resolve_handler(
+ const boost::system::error_code& ec,
+ tcp::resolver::iterator i)
+ {
+ if (!ec)
+ {
+ tcp::resolver::iterator end;
+ boost::asio::async_connect(s, i, end,
+ my_connect_condition(),
+ connect_handler);
+ }
+ }
+
+ // ...
+
+ void connect_handler(
+ const boost::system::error_code& ec,
+ tcp::resolver::iterator i)
+ {
+ if (ec)
+ {
+ // An error occurred.
+ }
+ else
+ {
+ std::cout << "Connected to: " << i->endpoint() << std::endl;
+ }
+ }
+
+
+
+
+
+
+
+[endsect]
+
+
+[endsect]
+
 [section:async_read async_read]
 
 [indexterm1 async_read]
@@ -2311,15 +2825,22 @@
 
   [
 
- [[link boost_asio.reference.basic_datagram_socket.native_type [*native_type]]]
+ [[link boost_asio.reference.basic_datagram_socket.native_handle_type [*native_handle_type]]]
     [The native representation of a socket. ]
   
   ]
 
   [
 
+ [[link boost_asio.reference.basic_datagram_socket.native_type [*native_type]]]
+ [(Deprecated: Use native_handle_type.) The native representation of a socket. ]
+
+ ]
+
+ [
+
     [[link boost_asio.reference.basic_datagram_socket.non_blocking_io [*non_blocking_io]]]
- [IO control command to set the blocking mode of the socket. ]
+ [(Deprecated: Use non_blocking().) IO control command to set the blocking mode of the socket. ]
   
   ]
 
@@ -2472,11 +2993,6 @@
   ]
   
   [
- [[link boost_asio.reference.basic_datagram_socket.io_service [*io_service]]]
- [(Deprecated: use get_io_service().) Get the io_service associated with the object. ]
- ]
-
- [
     [[link boost_asio.reference.basic_datagram_socket.is_open [*is_open]]]
     [Determine whether the socket is open. ]
   ]
@@ -2495,10 +3011,29 @@
   
   [
     [[link boost_asio.reference.basic_datagram_socket.native [*native]]]
+ [(Deprecated: Use native_handle().) Get the native socket representation. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_datagram_socket.native_handle [*native_handle]]]
     [Get the native socket representation. ]
   ]
   
   [
+ [[link boost_asio.reference.basic_datagram_socket.native_non_blocking [*native_non_blocking]]]
+ [Gets the non-blocking mode of the native socket implementation.
+
+ Sets the non-blocking mode of the native socket implementation. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_datagram_socket.non_blocking [*non_blocking]]]
+ [Gets the non-blocking mode of the socket.
+
+ Sets the non-blocking mode of the socket. ]
+ ]
+
+ [
     [[link boost_asio.reference.basic_datagram_socket.open [*open]]]
     [Open the socket using the specified protocol. ]
   ]
@@ -2555,6 +3090,11 @@
   ]
 
   [
+ [[link boost_asio.reference.basic_datagram_socket.message_end_of_record [*message_end_of_record]]]
+ [Specifies that the data marks the end of a record. ]
+ ]
+
+ [
     [[link boost_asio.reference.basic_datagram_socket.message_out_of_band [*message_out_of_band]]]
     [Process out-of-band data. ]
   ]
@@ -2607,12 +3147,12 @@
 
   void ``[link boost_asio.reference.basic_datagram_socket.assign.overload1 assign]``(
       const protocol_type & protocol,
- const native_type & native_socket);
+ const native_handle_type & native_socket);
   `` [''''&raquo;''' [link boost_asio.reference.basic_datagram_socket.assign.overload1 more...]]``
 
   boost::system::error_code ``[link boost_asio.reference.basic_datagram_socket.assign.overload2 assign]``(
       const protocol_type & protocol,
- const native_type & native_socket,
+ const native_handle_type & native_socket,
       boost::system::error_code & ec);
   `` [''''&raquo;''' [link boost_asio.reference.basic_datagram_socket.assign.overload2 more...]]``
 
@@ -2628,7 +3168,7 @@
 
   void assign(
       const protocol_type & protocol,
- const native_type & native_socket);
+ const native_handle_type & native_socket);
 
 
 
@@ -2647,7 +3187,7 @@
 
   boost::system::error_code assign(
       const protocol_type & protocol,
- const native_type & native_socket,
+ const native_handle_type & native_socket,
       boost::system::error_code & ec);
 
 
@@ -3464,7 +4004,7 @@
   ``[link boost_asio.reference.basic_datagram_socket.basic_datagram_socket.overload4 basic_datagram_socket]``(
       boost::asio::io_service & io_service,
       const protocol_type & protocol,
- const native_type & native_socket);
+ const native_handle_type & native_socket);
   `` [''''&raquo;''' [link boost_asio.reference.basic_datagram_socket.basic_datagram_socket.overload4 more...]]``
 
 
@@ -3590,7 +4130,7 @@
   basic_datagram_socket(
       boost::asio::io_service & io_service,
       const protocol_type & protocol,
- const native_type & native_socket);
+ const native_handle_type & native_socket);
 
 
 This constructor creates a datagram socket object to hold an existing native socket.
@@ -4716,32 +5256,6 @@
 [endsect]
 
 
-[section:io_service basic_datagram_socket::io_service]
-
-
-['Inherited from basic_io_object.]
-
-[indexterm2 io_service..basic_datagram_socket]
-(Deprecated: use `get_io_service()`.) Get the [link boost_asio.reference.io_service `io_service`] associated with the object.
-
-
- boost::asio::io_service & io_service();
-
-
-This function may be used to obtain the [link boost_asio.reference.io_service `io_service`] object that the I/O object uses to dispatch handlers for asynchronous operations.
-
-
-[heading Return Value]
-
-A reference to the [link boost_asio.reference.io_service `io_service`] object that the I/O object will use to dispatch handlers. Ownership is not transferred to the caller.
-
-
-
-
-[endsect]
-
-
-
 [section:is_open basic_datagram_socket::is_open]
 
 
@@ -5150,15 +5664,22 @@
 
   [
 
- [[link boost_asio.reference.basic_socket.native_type [*native_type]]]
+ [[link boost_asio.reference.basic_socket.native_handle_type [*native_handle_type]]]
     [The native representation of a socket. ]
   
   ]
 
   [
 
+ [[link boost_asio.reference.basic_socket.native_type [*native_type]]]
+ [(Deprecated: Use native_handle_type.) The native representation of a socket. ]
+
+ ]
+
+ [
+
     [[link boost_asio.reference.basic_socket.non_blocking_io [*non_blocking_io]]]
- [IO control command to set the blocking mode of the socket. ]
+ [(Deprecated: Use non_blocking().) IO control command to set the blocking mode of the socket. ]
   
   ]
 
@@ -5291,11 +5812,6 @@
   ]
   
   [
- [[link boost_asio.reference.basic_socket.io_service [*io_service]]]
- [(Deprecated: use get_io_service().) Get the io_service associated with the object. ]
- ]
-
- [
     [[link boost_asio.reference.basic_socket.is_open [*is_open]]]
     [Determine whether the socket is open. ]
   ]
@@ -5314,10 +5830,29 @@
   
   [
     [[link boost_asio.reference.basic_socket.native [*native]]]
+ [(Deprecated: Use native_handle().) Get the native socket representation. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_socket.native_handle [*native_handle]]]
     [Get the native socket representation. ]
   ]
   
   [
+ [[link boost_asio.reference.basic_socket.native_non_blocking [*native_non_blocking]]]
+ [Gets the non-blocking mode of the native socket implementation.
+
+ Sets the non-blocking mode of the native socket implementation. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_socket.non_blocking [*non_blocking]]]
+ [Gets the non-blocking mode of the socket.
+
+ Sets the non-blocking mode of the socket. ]
+ ]
+
+ [
     [[link boost_asio.reference.basic_socket.open [*open]]]
     [Open the socket using the specified protocol. ]
   ]
@@ -5365,6 +5900,11 @@
   ]
 
   [
+ [[link boost_asio.reference.basic_socket.message_end_of_record [*message_end_of_record]]]
+ [Specifies that the data marks the end of a record. ]
+ ]
+
+ [
     [[link boost_asio.reference.basic_socket.message_out_of_band [*message_out_of_band]]]
     [Process out-of-band data. ]
   ]
@@ -5449,6 +5989,23 @@
 
 
 
+[section:message_end_of_record basic_datagram_socket::message_end_of_record]
+
+
+['Inherited from socket_base.]
+
+[indexterm2 message_end_of_record..basic_datagram_socket]
+Specifies that the data marks the end of a record.
+
+
+ static const int message_end_of_record = implementation_defined;
+
+
+
+[endsect]
+
+
+
 [section:message_flags basic_datagram_socket::message_flags]
 
 
@@ -5513,7 +6070,7 @@
 ['Inherited from basic_socket.]
 
 [indexterm2 native..basic_datagram_socket]
-Get the native socket representation.
+(Deprecated: Use `native_handle()`.) Get the native socket representation.
 
 
   native_type native();
@@ -5526,13 +6083,32 @@
 
 
 
-[section:native_type basic_datagram_socket::native_type]
+[section:native_handle basic_datagram_socket::native_handle]
 
-[indexterm2 native_type..basic_datagram_socket]
+
+['Inherited from basic_socket.]
+
+[indexterm2 native_handle..basic_datagram_socket]
+Get the native socket representation.
+
+
+ native_handle_type native_handle();
+
+
+This function may be used to obtain the underlying representation of the socket. This is intended to allow access to native socket functionality that is not otherwise provided.
+
+
+[endsect]
+
+
+
+[section:native_handle_type basic_datagram_socket::native_handle_type]
+
+[indexterm2 native_handle_type..basic_datagram_socket]
 The native representation of a socket.
 
 
- typedef DatagramSocketService::native_type native_type;
+ typedef DatagramSocketService::native_handle_type native_handle_type;
 
 
 
@@ -5546,78 +6122,147 @@
 [endsect]
 
 
+[section:native_non_blocking basic_datagram_socket::native_non_blocking]
 
-[section:non_blocking_io basic_datagram_socket::non_blocking_io]
+[indexterm2 native_non_blocking..basic_datagram_socket]
+Gets the non-blocking mode of the native socket implementation.
 
 
-['Inherited from socket_base.]
+ bool ``[link boost_asio.reference.basic_datagram_socket.native_non_blocking.overload1 native_non_blocking]``() const;
+ `` [''''&raquo;''' [link boost_asio.reference.basic_datagram_socket.native_non_blocking.overload1 more...]]``
 
-[indexterm2 non_blocking_io..basic_datagram_socket]
-IO control command to set the blocking mode of the socket.
 
+Sets the non-blocking mode of the native socket implementation.
 
- typedef implementation_defined non_blocking_io;
 
+ void ``[link boost_asio.reference.basic_datagram_socket.native_non_blocking.overload2 native_non_blocking]``(
+ bool mode);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_datagram_socket.native_non_blocking.overload2 more...]]``
 
+ boost::system::error_code ``[link boost_asio.reference.basic_datagram_socket.native_non_blocking.overload3 native_non_blocking]``(
+ bool mode,
+ boost::system::error_code & ec);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_datagram_socket.native_non_blocking.overload3 more...]]``
 
-Implements the FIONBIO IO control command.
 
+[section:overload1 basic_datagram_socket::native_non_blocking (1 of 3 overloads)]
 
-[heading Example]
-
 
+['Inherited from basic_socket.]
 
- boost::asio::ip::tcp::socket socket(io_service);
- ...
- boost::asio::socket_base::non_blocking_io command(true);
- socket.io_control(command);
 
+Gets the non-blocking mode of the native socket implementation.
 
 
+ bool native_non_blocking() const;
 
 
+This function is used to retrieve the non-blocking mode of the underlying native socket. This mode has no effect on the behaviour of the socket object's synchronous operations.
 
 
-[heading Requirements]
+[heading Return Value]
+
+`true` if the underlying socket is in non-blocking mode and direct system calls may fail with `boost::asio::error::would_block` (or the equivalent system error).
 
-[*Header: ][^boost/asio/basic_datagram_socket.hpp]
 
-[*Convenience header: ][^boost/asio.hpp]
+[heading Remarks]
+
+The current non-blocking mode is cached by the socket object. Consequently, the return value may be incorrect if the non-blocking mode was set directly on the native socket.
 
 
-[endsect]
+[heading Example]
+
+This function is 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 following example illustrates how Linux's `sendfile` system call might be encapsulated:
 
+ template <typename Handler>
+ struct sendfile_op
+ {
+ tcp::socket& sock_;
+ int fd_;
+ Handler handler_;
+ off_t offset_;
+ std::size_t total_bytes_transferred_;
+
+ // Function call operator meeting WriteHandler requirements.
+ // Used as the handler for the async_write_some operation.
+ void operator()(boost::system::error_code ec, std::size_t)
+ {
+ // Put the underlying socket into non-blocking mode.
+ if (!ec)
+ if (!sock_.native_non_blocking())
+ sock_.native_non_blocking(true, ec);
+
+ if (!ec)
+ {
+ for (;;)
+ {
+ // Try the system call.
+ errno = 0;
+ int n = ::sendfile(sock_.native_handle(), fd_, &offset_, 65536);
+ ec = boost::system::error_code(n < 0 ? errno : 0,
+ boost::asio::error::get_system_category());
+ total_bytes_transferred_ += ec ? 0 : n;
+
+ // Retry operation immediately if interrupted by signal.
+ if (ec == boost::asio::error::interrupted)
+ continue;
+
+ // Check if we need to run the operation again.
+ if (ec == boost::asio::error::would_block
+ || ec == boost::asio::error::try_again)
+ {
+ // We have to wait for the socket to become ready again.
+ sock_.async_write_some(boost::asio::null_buffers(), *this);
+ return;
+ }
+
+ if (ec || n == 0)
+ {
+ // An error occurred, or we have reached the end of the file.
+ // Either way we must exit the loop so we can call the handler.
+ break;
+ }
+
+ // Loop around to try calling sendfile again.
+ }
+ }
 
-[section:open basic_datagram_socket::open]
+ // Pass result back to user's handler.
+ handler_(ec, total_bytes_transferred_);
+ }
+ };
 
-[indexterm2 open..basic_datagram_socket]
-Open the socket using the specified protocol.
+ template <typename Handler>
+ void async_sendfile(tcp::socket& sock, int fd, Handler h)
+ {
+ sendfile_op<Handler> op = { sock, fd, h, 0, 0 };
+ sock.async_write_some(boost::asio::null_buffers(), op);
+ }
 
 
- void ``[link boost_asio.reference.basic_datagram_socket.open.overload1 open]``(
- const protocol_type & protocol = protocol_type());
- `` [''''&raquo;''' [link boost_asio.reference.basic_datagram_socket.open.overload1 more...]]``
 
- boost::system::error_code ``[link boost_asio.reference.basic_datagram_socket.open.overload2 open]``(
- const protocol_type & protocol,
- boost::system::error_code & ec);
- `` [''''&raquo;''' [link boost_asio.reference.basic_datagram_socket.open.overload2 more...]]``
 
 
-[section:overload1 basic_datagram_socket::open (1 of 2 overloads)]
+
+
+[endsect]
+
+
+
+[section:overload2 basic_datagram_socket::native_non_blocking (2 of 3 overloads)]
 
 
 ['Inherited from basic_socket.]
 
 
-Open the socket using the specified protocol.
+Sets the non-blocking mode of the native socket implementation.
 
 
- void open(
- const protocol_type & protocol = protocol_type());
+ void native_non_blocking(
+ bool mode);
 
 
-This function opens the socket so that it will use the specified protocol.
+This function is used to modify the non-blocking mode of the underlying native socket. It has no effect on the behaviour of the socket object's synchronous operations.
 
 
 [heading Parameters]
@@ -5625,7 +6270,7 @@
 
 [variablelist
   
-[[protocol][An object specifying protocol parameters to be used.]]
+[[mode][If `true`, the underlying socket is put into non-blocking mode and direct system calls may fail with `boost::asio::error::would_block` (or the equivalent system error).]]
 
 ]
 
@@ -5635,17 +6280,79 @@
 
 [variablelist
   
-[[boost::system::system_error][Thrown on failure.]]
+[[boost::system::system_error][Thrown on failure. If the `mode` is `false`, but the current value of `non_blocking()` is `true`, this function fails with `boost::asio::error::invalid_argument`, as the combination does not make sense.]]
 
 ]
 
 
 [heading Example]
   
+This function is 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 following example illustrates how Linux's `sendfile` system call might be encapsulated:
 
+ template <typename Handler>
+ struct sendfile_op
+ {
+ tcp::socket& sock_;
+ int fd_;
+ Handler handler_;
+ off_t offset_;
+ std::size_t total_bytes_transferred_;
+
+ // Function call operator meeting WriteHandler requirements.
+ // Used as the handler for the async_write_some operation.
+ void operator()(boost::system::error_code ec, std::size_t)
+ {
+ // Put the underlying socket into non-blocking mode.
+ if (!ec)
+ if (!sock_.native_non_blocking())
+ sock_.native_non_blocking(true, ec);
+
+ if (!ec)
+ {
+ for (;;)
+ {
+ // Try the system call.
+ errno = 0;
+ int n = ::sendfile(sock_.native_handle(), fd_, &offset_, 65536);
+ ec = boost::system::error_code(n < 0 ? errno : 0,
+ boost::asio::error::get_system_category());
+ total_bytes_transferred_ += ec ? 0 : n;
+
+ // Retry operation immediately if interrupted by signal.
+ if (ec == boost::asio::error::interrupted)
+ continue;
+
+ // Check if we need to run the operation again.
+ if (ec == boost::asio::error::would_block
+ || ec == boost::asio::error::try_again)
+ {
+ // We have to wait for the socket to become ready again.
+ sock_.async_write_some(boost::asio::null_buffers(), *this);
+ return;
+ }
+
+ if (ec || n == 0)
+ {
+ // An error occurred, or we have reached the end of the file.
+ // Either way we must exit the loop so we can call the handler.
+ break;
+ }
+
+ // Loop around to try calling sendfile again.
+ }
+ }
 
- boost::asio::ip::tcp::socket socket(io_service);
- socket.open(boost::asio::ip::tcp::v4());
+ // Pass result back to user's handler.
+ handler_(ec, total_bytes_transferred_);
+ }
+ };
+
+ template <typename Handler>
+ void async_sendfile(tcp::socket& sock, int fd, Handler h)
+ {
+ sendfile_op<Handler> op = { sock, fd, h, 0, 0 };
+ sock.async_write_some(boost::asio::null_buffers(), op);
+ }
 
 
 
@@ -5657,21 +6364,21 @@
 
 
 
-[section:overload2 basic_datagram_socket::open (2 of 2 overloads)]
+[section:overload3 basic_datagram_socket::native_non_blocking (3 of 3 overloads)]
 
 
 ['Inherited from basic_socket.]
 
 
-Open the socket using the specified protocol.
+Sets the non-blocking mode of the native socket implementation.
 
 
- boost::system::error_code open(
- const protocol_type & protocol,
+ boost::system::error_code native_non_blocking(
+ bool mode,
       boost::system::error_code & ec);
 
 
-This function opens the socket so that it will use the specified protocol.
+This function is used to modify the non-blocking mode of the underlying native socket. It has no effect on the behaviour of the socket object's synchronous operations.
 
 
 [heading Parameters]
@@ -5679,24 +6386,81 @@
 
 [variablelist
   
-[[protocol][An object specifying which protocol is to be used.]]
+[[mode][If `true`, the underlying socket is put into non-blocking mode and direct system calls may fail with `boost::asio::error::would_block` (or the equivalent system error).]]
 
-[[ec][Set to indicate what error occurred, if any.]]
+[[ec][Set to indicate what error occurred, if any. If the `mode` is `false`, but the current value of `non_blocking()` is `true`, this function fails with `boost::asio::error::invalid_argument`, as the combination does not make sense.]]
 
 ]
 
 
 [heading Example]
   
+This function is 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 following example illustrates how Linux's `sendfile` system call might be encapsulated:
 
+ template <typename Handler>
+ struct sendfile_op
+ {
+ tcp::socket& sock_;
+ int fd_;
+ Handler handler_;
+ off_t offset_;
+ std::size_t total_bytes_transferred_;
+
+ // Function call operator meeting WriteHandler requirements.
+ // Used as the handler for the async_write_some operation.
+ void operator()(boost::system::error_code ec, std::size_t)
+ {
+ // Put the underlying socket into non-blocking mode.
+ if (!ec)
+ if (!sock_.native_non_blocking())
+ sock_.native_non_blocking(true, ec);
+
+ if (!ec)
+ {
+ for (;;)
+ {
+ // Try the system call.
+ errno = 0;
+ int n = ::sendfile(sock_.native_handle(), fd_, &offset_, 65536);
+ ec = boost::system::error_code(n < 0 ? errno : 0,
+ boost::asio::error::get_system_category());
+ total_bytes_transferred_ += ec ? 0 : n;
+
+ // Retry operation immediately if interrupted by signal.
+ if (ec == boost::asio::error::interrupted)
+ continue;
+
+ // Check if we need to run the operation again.
+ if (ec == boost::asio::error::would_block
+ || ec == boost::asio::error::try_again)
+ {
+ // We have to wait for the socket to become ready again.
+ sock_.async_write_some(boost::asio::null_buffers(), *this);
+ return;
+ }
+
+ if (ec || n == 0)
+ {
+ // An error occurred, or we have reached the end of the file.
+ // Either way we must exit the loop so we can call the handler.
+ break;
+ }
+
+ // Loop around to try calling sendfile again.
+ }
+ }
 
- boost::asio::ip::tcp::socket socket(io_service);
- boost::system::error_code ec;
- socket.open(boost::asio::ip::tcp::v4(), ec);
- if (ec)
+ // Pass result back to user's handler.
+ handler_(ec, total_bytes_transferred_);
+ }
+ };
+
+ template <typename Handler>
+ void async_sendfile(tcp::socket& sock, int fd, Handler h)
    {
- // An error occurred.
- }
+ sendfile_op<Handler> op = { sock, fd, h, 0, 0 };
+ sock.async_write_some(boost::asio::null_buffers(), op);
+ }
 
 
 
@@ -5710,13 +6474,13 @@
 [endsect]
 
 
-[section:protocol_type basic_datagram_socket::protocol_type]
+[section:native_type basic_datagram_socket::native_type]
 
-[indexterm2 protocol_type..basic_datagram_socket]
-The protocol type.
+[indexterm2 native_type..basic_datagram_socket]
+(Deprecated: Use native\_handle\_type.) The native representation of a socket.
 
 
- typedef Protocol protocol_type;
+ typedef DatagramSocketService::native_handle_type native_type;
 
 
 
@@ -5730,66 +6494,386 @@
 [endsect]
 
 
-[section:receive basic_datagram_socket::receive]
+[section:non_blocking basic_datagram_socket::non_blocking]
 
-[indexterm2 receive..basic_datagram_socket]
-Receive some data on a connected socket.
+[indexterm2 non_blocking..basic_datagram_socket]
+Gets the non-blocking mode of the socket.
 
 
- template<
- typename ``[link boost_asio.reference.MutableBufferSequence MutableBufferSequence]``>
- std::size_t ``[link boost_asio.reference.basic_datagram_socket.receive.overload1 receive]``(
- const MutableBufferSequence & buffers);
- `` [''''&raquo;''' [link boost_asio.reference.basic_datagram_socket.receive.overload1 more...]]``
+ bool ``[link boost_asio.reference.basic_datagram_socket.non_blocking.overload1 non_blocking]``() const;
+ `` [''''&raquo;''' [link boost_asio.reference.basic_datagram_socket.non_blocking.overload1 more...]]``
 
- template<
- typename ``[link boost_asio.reference.MutableBufferSequence MutableBufferSequence]``>
- std::size_t ``[link boost_asio.reference.basic_datagram_socket.receive.overload2 receive]``(
- const MutableBufferSequence & buffers,
- socket_base::message_flags flags);
- `` [''''&raquo;''' [link boost_asio.reference.basic_datagram_socket.receive.overload2 more...]]``
 
- template<
- typename ``[link boost_asio.reference.MutableBufferSequence MutableBufferSequence]``>
- std::size_t ``[link boost_asio.reference.basic_datagram_socket.receive.overload3 receive]``(
- const MutableBufferSequence & buffers,
- socket_base::message_flags flags,
- boost::system::error_code & ec);
- `` [''''&raquo;''' [link boost_asio.reference.basic_datagram_socket.receive.overload3 more...]]``
+Sets the non-blocking mode of the socket.
 
 
-[section:overload1 basic_datagram_socket::receive (1 of 3 overloads)]
+ void ``[link boost_asio.reference.basic_datagram_socket.non_blocking.overload2 non_blocking]``(
+ bool mode);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_datagram_socket.non_blocking.overload2 more...]]``
 
+ boost::system::error_code ``[link boost_asio.reference.basic_datagram_socket.non_blocking.overload3 non_blocking]``(
+ bool mode,
+ boost::system::error_code & ec);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_datagram_socket.non_blocking.overload3 more...]]``
 
-Receive some data on a connected socket.
 
+[section:overload1 basic_datagram_socket::non_blocking (1 of 3 overloads)]
 
- template<
- typename ``[link boost_asio.reference.MutableBufferSequence MutableBufferSequence]``>
- std::size_t receive(
- const MutableBufferSequence & buffers);
 
+['Inherited from basic_socket.]
 
-This function is used to receive data on the datagram socket. The function call will block until data has been received successfully or an error occurs.
 
+Gets the non-blocking mode of the socket.
 
-[heading Parameters]
-
 
-[variablelist
-
-[[buffers][One or more buffers into which the data will be received.]]
+ bool non_blocking() const;
 
-]
 
 
 [heading Return Value]
       
-The number of bytes received.
+`true` if the socket's synchronous operations will fail with `boost::asio::error::would_block` if they are unable to perform the requested operation immediately. If `false`, synchronous operations will block until complete.
 
 
-[heading Exceptions]
-
+[heading Remarks]
+
+The non-blocking mode has no effect on the behaviour of asynchronous operations. Asynchronous operations will never fail with the error `boost::asio::error::would_block`.
+
+
+
+
+[endsect]
+
+
+
+[section:overload2 basic_datagram_socket::non_blocking (2 of 3 overloads)]
+
+
+['Inherited from basic_socket.]
+
+
+Sets the non-blocking mode of the socket.
+
+
+ void non_blocking(
+ bool mode);
+
+
+
+[heading Parameters]
+
+
+[variablelist
+
+[[mode][If `true`, the socket's synchronous operations will fail with `boost::asio::error::would_block` if they are unable to perform the requested operation immediately. If `false`, synchronous operations will block until complete.]]
+
+]
+
+
+[heading Exceptions]
+
+
+[variablelist
+
+[[boost::system::system_error][Thrown on failure.]]
+
+]
+
+
+[heading Remarks]
+
+The non-blocking mode has no effect on the behaviour of asynchronous operations. Asynchronous operations will never fail with the error `boost::asio::error::would_block`.
+
+
+
+
+[endsect]
+
+
+
+[section:overload3 basic_datagram_socket::non_blocking (3 of 3 overloads)]
+
+
+['Inherited from basic_socket.]
+
+
+Sets the non-blocking mode of the socket.
+
+
+ boost::system::error_code non_blocking(
+ bool mode,
+ boost::system::error_code & ec);
+
+
+
+[heading Parameters]
+
+
+[variablelist
+
+[[mode][If `true`, the socket's synchronous operations will fail with `boost::asio::error::would_block` if they are unable to perform the requested operation immediately. If `false`, synchronous operations will block until complete.]]
+
+[[ec][Set to indicate what error occurred, if any.]]
+
+]
+
+
+[heading Remarks]
+
+The non-blocking mode has no effect on the behaviour of asynchronous operations. Asynchronous operations will never fail with the error `boost::asio::error::would_block`.
+
+
+
+
+[endsect]
+
+
+[endsect]
+
+
+[section:non_blocking_io basic_datagram_socket::non_blocking_io]
+
+
+['Inherited from socket_base.]
+
+[indexterm2 non_blocking_io..basic_datagram_socket]
+(Deprecated: Use non\_blocking().) IO control command to set the blocking mode of the socket.
+
+
+ typedef implementation_defined non_blocking_io;
+
+
+
+Implements the FIONBIO IO control command.
+
+
+[heading Example]
+
+
+
+ boost::asio::ip::tcp::socket socket(io_service);
+ ...
+ boost::asio::socket_base::non_blocking_io command(true);
+ socket.io_control(command);
+
+
+
+
+
+
+
+[heading Requirements]
+
+[*Header: ][^boost/asio/basic_datagram_socket.hpp]
+
+[*Convenience header: ][^boost/asio.hpp]
+
+
+[endsect]
+
+
+[section:open basic_datagram_socket::open]
+
+[indexterm2 open..basic_datagram_socket]
+Open the socket using the specified protocol.
+
+
+ void ``[link boost_asio.reference.basic_datagram_socket.open.overload1 open]``(
+ const protocol_type & protocol = protocol_type());
+ `` [''''&raquo;''' [link boost_asio.reference.basic_datagram_socket.open.overload1 more...]]``
+
+ boost::system::error_code ``[link boost_asio.reference.basic_datagram_socket.open.overload2 open]``(
+ const protocol_type & protocol,
+ boost::system::error_code & ec);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_datagram_socket.open.overload2 more...]]``
+
+
+[section:overload1 basic_datagram_socket::open (1 of 2 overloads)]
+
+
+['Inherited from basic_socket.]
+
+
+Open the socket using the specified protocol.
+
+
+ void open(
+ const protocol_type & protocol = protocol_type());
+
+
+This function opens the socket so that it will use the specified protocol.
+
+
+[heading Parameters]
+
+
+[variablelist
+
+[[protocol][An object specifying protocol parameters to be used.]]
+
+]
+
+
+[heading Exceptions]
+
+
+[variablelist
+
+[[boost::system::system_error][Thrown on failure.]]
+
+]
+
+
+[heading Example]
+
+
+
+ boost::asio::ip::tcp::socket socket(io_service);
+ socket.open(boost::asio::ip::tcp::v4());
+
+
+
+
+
+
+
+[endsect]
+
+
+
+[section:overload2 basic_datagram_socket::open (2 of 2 overloads)]
+
+
+['Inherited from basic_socket.]
+
+
+Open the socket using the specified protocol.
+
+
+ boost::system::error_code open(
+ const protocol_type & protocol,
+ boost::system::error_code & ec);
+
+
+This function opens the socket so that it will use the specified protocol.
+
+
+[heading Parameters]
+
+
+[variablelist
+
+[[protocol][An object specifying which protocol is to be used.]]
+
+[[ec][Set to indicate what error occurred, if any.]]
+
+]
+
+
+[heading Example]
+
+
+
+ boost::asio::ip::tcp::socket socket(io_service);
+ boost::system::error_code ec;
+ socket.open(boost::asio::ip::tcp::v4(), ec);
+ if (ec)
+ {
+ // An error occurred.
+ }
+
+
+
+
+
+
+
+[endsect]
+
+
+[endsect]
+
+
+[section:protocol_type basic_datagram_socket::protocol_type]
+
+[indexterm2 protocol_type..basic_datagram_socket]
+The protocol type.
+
+
+ typedef Protocol protocol_type;
+
+
+
+[heading Requirements]
+
+[*Header: ][^boost/asio/basic_datagram_socket.hpp]
+
+[*Convenience header: ][^boost/asio.hpp]
+
+
+[endsect]
+
+
+[section:receive basic_datagram_socket::receive]
+
+[indexterm2 receive..basic_datagram_socket]
+Receive some data on a connected socket.
+
+
+ template<
+ typename ``[link boost_asio.reference.MutableBufferSequence MutableBufferSequence]``>
+ std::size_t ``[link boost_asio.reference.basic_datagram_socket.receive.overload1 receive]``(
+ const MutableBufferSequence & buffers);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_datagram_socket.receive.overload1 more...]]``
+
+ template<
+ typename ``[link boost_asio.reference.MutableBufferSequence MutableBufferSequence]``>
+ std::size_t ``[link boost_asio.reference.basic_datagram_socket.receive.overload2 receive]``(
+ const MutableBufferSequence & buffers,
+ socket_base::message_flags flags);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_datagram_socket.receive.overload2 more...]]``
+
+ template<
+ typename ``[link boost_asio.reference.MutableBufferSequence MutableBufferSequence]``>
+ std::size_t ``[link boost_asio.reference.basic_datagram_socket.receive.overload3 receive]``(
+ const MutableBufferSequence & buffers,
+ socket_base::message_flags flags,
+ boost::system::error_code & ec);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_datagram_socket.receive.overload3 more...]]``
+
+
+[section:overload1 basic_datagram_socket::receive (1 of 3 overloads)]
+
+
+Receive some data on a connected socket.
+
+
+ template<
+ typename ``[link boost_asio.reference.MutableBufferSequence MutableBufferSequence]``>
+ std::size_t receive(
+ const MutableBufferSequence & buffers);
+
+
+This function is used to receive data on the datagram socket. The function call will block until data has been received successfully or an error occurs.
+
+
+[heading Parameters]
+
+
+[variablelist
+
+[[buffers][One or more buffers into which the data will be received.]]
+
+]
+
+
+[heading Return Value]
+
+The number of bytes received.
+
+
+[heading Exceptions]
+
 
 [variablelist
   
@@ -7297,6 +8381,11 @@
   ]
   
   [
+ [[link boost_asio.reference.basic_deadline_timer.cancel_one [*cancel_one]]]
+ [Cancels one asynchronous operation that is waiting on the timer. ]
+ ]
+
+ [
     [[link boost_asio.reference.basic_deadline_timer.expires_at [*expires_at]]]
     [Get the timer's expiry time as an absolute time.
 
@@ -7316,11 +8405,6 @@
   ]
   
   [
- [[link boost_asio.reference.basic_deadline_timer.io_service [*io_service]]]
- [(Deprecated: use get_io_service().) Get the io_service associated with the object. ]
- ]
-
- [
     [[link boost_asio.reference.basic_deadline_timer.wait [*wait]]]
     [Perform a blocking wait on the timer. ]
   ]
@@ -7719,6 +8803,114 @@
 
 [endsect]
 
+[section:cancel_one basic_deadline_timer::cancel_one]
+
+[indexterm2 cancel_one..basic_deadline_timer]
+Cancels one asynchronous operation that is waiting on the timer.
+
+
+ std::size_t ``[link boost_asio.reference.basic_deadline_timer.cancel_one.overload1 cancel_one]``();
+ `` [''''&raquo;''' [link boost_asio.reference.basic_deadline_timer.cancel_one.overload1 more...]]``
+
+ std::size_t ``[link boost_asio.reference.basic_deadline_timer.cancel_one.overload2 cancel_one]``(
+ boost::system::error_code & ec);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_deadline_timer.cancel_one.overload2 more...]]``
+
+
+[section:overload1 basic_deadline_timer::cancel_one (1 of 2 overloads)]
+
+
+Cancels one asynchronous operation that is waiting on the timer.
+
+
+ std::size_t cancel_one();
+
+
+This function forces the completion of one pending asynchronous wait operation against the timer. Handlers are cancelled in FIFO order. The handler for the cancelled operation will be invoked with the `boost::asio::error::operation_aborted` error code.
+
+Cancelling the timer does not change the expiry time.
+
+
+[heading Return Value]
+
+The number of asynchronous operations that were cancelled. That is, either 0 or 1.
+
+
+[heading Exceptions]
+
+
+[variablelist
+
+[[boost::system::system_error][Thrown on failure.]]
+
+]
+
+
+[heading Remarks]
+
+If the timer has already expired when `cancel_one()` is called, then the handlers for asynchronous wait operations will:
+
+
+* have already been invoked; or
+
+
+* have been queued for invocation in the near future.
+
+These handlers can no longer be cancelled, and therefore are passed an error code that indicates the successful completion of the wait operation.
+
+
+[endsect]
+
+
+
+[section:overload2 basic_deadline_timer::cancel_one (2 of 2 overloads)]
+
+
+Cancels one asynchronous operation that is waiting on the timer.
+
+
+ std::size_t cancel_one(
+ boost::system::error_code & ec);
+
+
+This function forces the completion of one pending asynchronous wait operation against the timer. Handlers are cancelled in FIFO order. The handler for the cancelled operation will be invoked with the `boost::asio::error::operation_aborted` error code.
+
+Cancelling the timer does not change the expiry time.
+
+
+[heading Parameters]
+
+
+[variablelist
+
+[[ec][Set to indicate what error occurred, if any.]]
+
+]
+
+
+[heading Return Value]
+
+The number of asynchronous operations that were cancelled. That is, either 0 or 1.
+
+
+[heading Remarks]
+
+If the timer has already expired when `cancel_one()` is called, then the handlers for asynchronous wait operations will:
+
+
+* have already been invoked; or
+
+
+* have been queued for invocation in the near future.
+
+These handlers can no longer be cancelled, and therefore are passed an error code that indicates the successful completion of the wait operation.
+
+
+[endsect]
+
+
+[endsect]
+
 
 [section:duration_type basic_deadline_timer::duration_type]
 
@@ -8094,32 +9286,6 @@
 
 
 
-[section:io_service basic_deadline_timer::io_service]
-
-
-['Inherited from basic_io_object.]
-
-[indexterm2 io_service..basic_deadline_timer]
-(Deprecated: use `get_io_service()`.) Get the [link boost_asio.reference.io_service `io_service`] associated with the object.
-
-
- boost::asio::io_service & io_service();
-
-
-This function may be used to obtain the [link boost_asio.reference.io_service `io_service`] object that the I/O object uses to dispatch handlers for asynchronous operations.
-
-
-[heading Return Value]
-
-A reference to the [link boost_asio.reference.io_service `io_service`] object that the I/O object will use to dispatch handlers. Ownership is not transferred to the caller.
-
-
-
-
-[endsect]
-
-
-
 [section:service basic_deadline_timer::service]
 
 
@@ -8318,11 +9484,6 @@
     [Get the io_service associated with the object. ]
   ]
   
- [
- [[link boost_asio.reference.basic_io_object.io_service [*io_service]]]
- [(Deprecated: use get_io_service().) Get the io_service associated with the object. ]
- ]
-
 ]
 
 [heading Protected Member Functions]
@@ -8444,29 +9605,6 @@
 
 
 
-[section:io_service basic_io_object::io_service]
-
-[indexterm2 io_service..basic_io_object]
-(Deprecated: use `get_io_service()`.) Get the [link boost_asio.reference.io_service `io_service`] associated with the object.
-
-
- boost::asio::io_service & io_service();
-
-
-This function may be used to obtain the [link boost_asio.reference.io_service `io_service`] object that the I/O object uses to dispatch handlers for asynchronous operations.
-
-
-[heading Return Value]
-
-A reference to the [link boost_asio.reference.io_service `io_service`] object that the I/O object will use to dispatch handlers. Ownership is not transferred to the caller.
-
-
-
-
-[endsect]
-
-
-
 [section:service basic_io_object::service]
 
 [indexterm2 service..basic_io_object]
@@ -8621,15 +9759,22 @@
 
   [
 
- [[link boost_asio.reference.basic_raw_socket.native_type [*native_type]]]
+ [[link boost_asio.reference.basic_raw_socket.native_handle_type [*native_handle_type]]]
     [The native representation of a socket. ]
   
   ]
 
   [
 
+ [[link boost_asio.reference.basic_raw_socket.native_type [*native_type]]]
+ [(Deprecated: Use native_handle_type.) The native representation of a socket. ]
+
+ ]
+
+ [
+
     [[link boost_asio.reference.basic_raw_socket.non_blocking_io [*non_blocking_io]]]
- [IO control command to set the blocking mode of the socket. ]
+ [(Deprecated: Use non_blocking().) IO control command to set the blocking mode of the socket. ]
   
   ]
 
@@ -8782,11 +9927,6 @@
   ]
   
   [
- [[link boost_asio.reference.basic_raw_socket.io_service [*io_service]]]
- [(Deprecated: use get_io_service().) Get the io_service associated with the object. ]
- ]
-
- [
     [[link boost_asio.reference.basic_raw_socket.is_open [*is_open]]]
     [Determine whether the socket is open. ]
   ]
@@ -8805,10 +9945,29 @@
   
   [
     [[link boost_asio.reference.basic_raw_socket.native [*native]]]
+ [(Deprecated: Use native_handle().) Get the native socket representation. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_raw_socket.native_handle [*native_handle]]]
     [Get the native socket representation. ]
   ]
   
   [
+ [[link boost_asio.reference.basic_raw_socket.native_non_blocking [*native_non_blocking]]]
+ [Gets the non-blocking mode of the native socket implementation.
+
+ Sets the non-blocking mode of the native socket implementation. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_raw_socket.non_blocking [*non_blocking]]]
+ [Gets the non-blocking mode of the socket.
+
+ Sets the non-blocking mode of the socket. ]
+ ]
+
+ [
     [[link boost_asio.reference.basic_raw_socket.open [*open]]]
     [Open the socket using the specified protocol. ]
   ]
@@ -8865,6 +10024,11 @@
   ]
 
   [
+ [[link boost_asio.reference.basic_raw_socket.message_end_of_record [*message_end_of_record]]]
+ [Specifies that the data marks the end of a record. ]
+ ]
+
+ [
     [[link boost_asio.reference.basic_raw_socket.message_out_of_band [*message_out_of_band]]]
     [Process out-of-band data. ]
   ]
@@ -8917,12 +10081,12 @@
 
   void ``[link boost_asio.reference.basic_raw_socket.assign.overload1 assign]``(
       const protocol_type & protocol,
- const native_type & native_socket);
+ const native_handle_type & native_socket);
   `` [''''&raquo;''' [link boost_asio.reference.basic_raw_socket.assign.overload1 more...]]``
 
   boost::system::error_code ``[link boost_asio.reference.basic_raw_socket.assign.overload2 assign]``(
       const protocol_type & protocol,
- const native_type & native_socket,
+ const native_handle_type & native_socket,
       boost::system::error_code & ec);
   `` [''''&raquo;''' [link boost_asio.reference.basic_raw_socket.assign.overload2 more...]]``
 
@@ -8938,7 +10102,7 @@
 
   void assign(
       const protocol_type & protocol,
- const native_type & native_socket);
+ const native_handle_type & native_socket);
 
 
 
@@ -8957,7 +10121,7 @@
 
   boost::system::error_code assign(
       const protocol_type & protocol,
- const native_type & native_socket,
+ const native_handle_type & native_socket,
       boost::system::error_code & ec);
 
 
@@ -9774,7 +10938,7 @@
   ``[link boost_asio.reference.basic_raw_socket.basic_raw_socket.overload4 basic_raw_socket]``(
       boost::asio::io_service & io_service,
       const protocol_type & protocol,
- const native_type & native_socket);
+ const native_handle_type & native_socket);
   `` [''''&raquo;''' [link boost_asio.reference.basic_raw_socket.basic_raw_socket.overload4 more...]]``
 
 
@@ -9900,7 +11064,7 @@
   basic_raw_socket(
       boost::asio::io_service & io_service,
       const protocol_type & protocol,
- const native_type & native_socket);
+ const native_handle_type & native_socket);
 
 
 This constructor creates a raw socket object to hold an existing native socket.
@@ -11026,32 +12190,6 @@
 [endsect]
 
 
-[section:io_service basic_raw_socket::io_service]
-
-
-['Inherited from basic_io_object.]
-
-[indexterm2 io_service..basic_raw_socket]
-(Deprecated: use `get_io_service()`.) Get the [link boost_asio.reference.io_service `io_service`] associated with the object.
-
-
- boost::asio::io_service & io_service();
-
-
-This function may be used to obtain the [link boost_asio.reference.io_service `io_service`] object that the I/O object uses to dispatch handlers for asynchronous operations.
-
-
-[heading Return Value]
-
-A reference to the [link boost_asio.reference.io_service `io_service`] object that the I/O object will use to dispatch handlers. Ownership is not transferred to the caller.
-
-
-
-
-[endsect]
-
-
-
 [section:is_open basic_raw_socket::is_open]
 
 
@@ -11460,15 +12598,22 @@
 
   [
 
- [[link boost_asio.reference.basic_socket.native_type [*native_type]]]
+ [[link boost_asio.reference.basic_socket.native_handle_type [*native_handle_type]]]
     [The native representation of a socket. ]
   
   ]
 
   [
 
- [[link boost_asio.reference.basic_socket.non_blocking_io [*non_blocking_io]]]
- [IO control command to set the blocking mode of the socket. ]
+ [[link boost_asio.reference.basic_socket.native_type [*native_type]]]
+ [(Deprecated: Use native_handle_type.) The native representation of a socket. ]
+
+ ]
+
+ [
+
+ [[link boost_asio.reference.basic_socket.non_blocking_io [*non_blocking_io]]]
+ [(Deprecated: Use non_blocking().) IO control command to set the blocking mode of the socket. ]
   
   ]
 
@@ -11601,11 +12746,6 @@
   ]
   
   [
- [[link boost_asio.reference.basic_socket.io_service [*io_service]]]
- [(Deprecated: use get_io_service().) Get the io_service associated with the object. ]
- ]
-
- [
     [[link boost_asio.reference.basic_socket.is_open [*is_open]]]
     [Determine whether the socket is open. ]
   ]
@@ -11624,10 +12764,29 @@
   
   [
     [[link boost_asio.reference.basic_socket.native [*native]]]
+ [(Deprecated: Use native_handle().) Get the native socket representation. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_socket.native_handle [*native_handle]]]
     [Get the native socket representation. ]
   ]
   
   [
+ [[link boost_asio.reference.basic_socket.native_non_blocking [*native_non_blocking]]]
+ [Gets the non-blocking mode of the native socket implementation.
+
+ Sets the non-blocking mode of the native socket implementation. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_socket.non_blocking [*non_blocking]]]
+ [Gets the non-blocking mode of the socket.
+
+ Sets the non-blocking mode of the socket. ]
+ ]
+
+ [
     [[link boost_asio.reference.basic_socket.open [*open]]]
     [Open the socket using the specified protocol. ]
   ]
@@ -11675,6 +12834,11 @@
   ]
 
   [
+ [[link boost_asio.reference.basic_socket.message_end_of_record [*message_end_of_record]]]
+ [Specifies that the data marks the end of a record. ]
+ ]
+
+ [
     [[link boost_asio.reference.basic_socket.message_out_of_band [*message_out_of_band]]]
     [Process out-of-band data. ]
   ]
@@ -11759,6 +12923,23 @@
 
 
 
+[section:message_end_of_record basic_raw_socket::message_end_of_record]
+
+
+['Inherited from socket_base.]
+
+[indexterm2 message_end_of_record..basic_raw_socket]
+Specifies that the data marks the end of a record.
+
+
+ static const int message_end_of_record = implementation_defined;
+
+
+
+[endsect]
+
+
+
 [section:message_flags basic_raw_socket::message_flags]
 
 
@@ -11823,7 +13004,7 @@
 ['Inherited from basic_socket.]
 
 [indexterm2 native..basic_raw_socket]
-Get the native socket representation.
+(Deprecated: Use `native_handle()`.) Get the native socket representation.
 
 
   native_type native();
@@ -11836,13 +13017,404 @@
 
 
 
+[section:native_handle basic_raw_socket::native_handle]
+
+
+['Inherited from basic_socket.]
+
+[indexterm2 native_handle..basic_raw_socket]
+Get the native socket representation.
+
+
+ native_handle_type native_handle();
+
+
+This function may be used to obtain the underlying representation of the socket. This is intended to allow access to native socket functionality that is not otherwise provided.
+
+
+[endsect]
+
+
+
+[section:native_handle_type basic_raw_socket::native_handle_type]
+
+[indexterm2 native_handle_type..basic_raw_socket]
+The native representation of a socket.
+
+
+ typedef RawSocketService::native_handle_type native_handle_type;
+
+
+
+[heading Requirements]
+
+[*Header: ][^boost/asio/basic_raw_socket.hpp]
+
+[*Convenience header: ][^boost/asio.hpp]
+
+
+[endsect]
+
+
+[section:native_non_blocking basic_raw_socket::native_non_blocking]
+
+[indexterm2 native_non_blocking..basic_raw_socket]
+Gets the non-blocking mode of the native socket implementation.
+
+
+ bool ``[link boost_asio.reference.basic_raw_socket.native_non_blocking.overload1 native_non_blocking]``() const;
+ `` [''''&raquo;''' [link boost_asio.reference.basic_raw_socket.native_non_blocking.overload1 more...]]``
+
+
+Sets the non-blocking mode of the native socket implementation.
+
+
+ void ``[link boost_asio.reference.basic_raw_socket.native_non_blocking.overload2 native_non_blocking]``(
+ bool mode);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_raw_socket.native_non_blocking.overload2 more...]]``
+
+ boost::system::error_code ``[link boost_asio.reference.basic_raw_socket.native_non_blocking.overload3 native_non_blocking]``(
+ bool mode,
+ boost::system::error_code & ec);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_raw_socket.native_non_blocking.overload3 more...]]``
+
+
+[section:overload1 basic_raw_socket::native_non_blocking (1 of 3 overloads)]
+
+
+['Inherited from basic_socket.]
+
+
+Gets the non-blocking mode of the native socket implementation.
+
+
+ bool native_non_blocking() const;
+
+
+This function is used to retrieve the non-blocking mode of the underlying native socket. This mode has no effect on the behaviour of the socket object's synchronous operations.
+
+
+[heading Return Value]
+
+`true` if the underlying socket is in non-blocking mode and direct system calls may fail with `boost::asio::error::would_block` (or the equivalent system error).
+
+
+[heading Remarks]
+
+The current non-blocking mode is cached by the socket object. Consequently, the return value may be incorrect if the non-blocking mode was set directly on the native socket.
+
+
+[heading Example]
+
+This function is 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 following example illustrates how Linux's `sendfile` system call might be encapsulated:
+
+ template <typename Handler>
+ struct sendfile_op
+ {
+ tcp::socket& sock_;
+ int fd_;
+ Handler handler_;
+ off_t offset_;
+ std::size_t total_bytes_transferred_;
+
+ // Function call operator meeting WriteHandler requirements.
+ // Used as the handler for the async_write_some operation.
+ void operator()(boost::system::error_code ec, std::size_t)
+ {
+ // Put the underlying socket into non-blocking mode.
+ if (!ec)
+ if (!sock_.native_non_blocking())
+ sock_.native_non_blocking(true, ec);
+
+ if (!ec)
+ {
+ for (;;)
+ {
+ // Try the system call.
+ errno = 0;
+ int n = ::sendfile(sock_.native_handle(), fd_, &offset_, 65536);
+ ec = boost::system::error_code(n < 0 ? errno : 0,
+ boost::asio::error::get_system_category());
+ total_bytes_transferred_ += ec ? 0 : n;
+
+ // Retry operation immediately if interrupted by signal.
+ if (ec == boost::asio::error::interrupted)
+ continue;
+
+ // Check if we need to run the operation again.
+ if (ec == boost::asio::error::would_block
+ || ec == boost::asio::error::try_again)
+ {
+ // We have to wait for the socket to become ready again.
+ sock_.async_write_some(boost::asio::null_buffers(), *this);
+ return;
+ }
+
+ if (ec || n == 0)
+ {
+ // An error occurred, or we have reached the end of the file.
+ // Either way we must exit the loop so we can call the handler.
+ break;
+ }
+
+ // Loop around to try calling sendfile again.
+ }
+ }
+
+ // Pass result back to user's handler.
+ handler_(ec, total_bytes_transferred_);
+ }
+ };
+
+ template <typename Handler>
+ void async_sendfile(tcp::socket& sock, int fd, Handler h)
+ {
+ sendfile_op<Handler> op = { sock, fd, h, 0, 0 };
+ sock.async_write_some(boost::asio::null_buffers(), op);
+ }
+
+
+
+
+
+
+
+[endsect]
+
+
+
+[section:overload2 basic_raw_socket::native_non_blocking (2 of 3 overloads)]
+
+
+['Inherited from basic_socket.]
+
+
+Sets the non-blocking mode of the native socket implementation.
+
+
+ void native_non_blocking(
+ bool mode);
+
+
+This function is used to modify the non-blocking mode of the underlying native socket. It has no effect on the behaviour of the socket object's synchronous operations.
+
+
+[heading Parameters]
+
+
+[variablelist
+
+[[mode][If `true`, the underlying socket is put into non-blocking mode and direct system calls may fail with `boost::asio::error::would_block` (or the equivalent system error).]]
+
+]
+
+
+[heading Exceptions]
+
+
+[variablelist
+
+[[boost::system::system_error][Thrown on failure. If the `mode` is `false`, but the current value of `non_blocking()` is `true`, this function fails with `boost::asio::error::invalid_argument`, as the combination does not make sense.]]
+
+]
+
+
+[heading Example]
+
+This function is 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 following example illustrates how Linux's `sendfile` system call might be encapsulated:
+
+ template <typename Handler>
+ struct sendfile_op
+ {
+ tcp::socket& sock_;
+ int fd_;
+ Handler handler_;
+ off_t offset_;
+ std::size_t total_bytes_transferred_;
+
+ // Function call operator meeting WriteHandler requirements.
+ // Used as the handler for the async_write_some operation.
+ void operator()(boost::system::error_code ec, std::size_t)
+ {
+ // Put the underlying socket into non-blocking mode.
+ if (!ec)
+ if (!sock_.native_non_blocking())
+ sock_.native_non_blocking(true, ec);
+
+ if (!ec)
+ {
+ for (;;)
+ {
+ // Try the system call.
+ errno = 0;
+ int n = ::sendfile(sock_.native_handle(), fd_, &offset_, 65536);
+ ec = boost::system::error_code(n < 0 ? errno : 0,
+ boost::asio::error::get_system_category());
+ total_bytes_transferred_ += ec ? 0 : n;
+
+ // Retry operation immediately if interrupted by signal.
+ if (ec == boost::asio::error::interrupted)
+ continue;
+
+ // Check if we need to run the operation again.
+ if (ec == boost::asio::error::would_block
+ || ec == boost::asio::error::try_again)
+ {
+ // We have to wait for the socket to become ready again.
+ sock_.async_write_some(boost::asio::null_buffers(), *this);
+ return;
+ }
+
+ if (ec || n == 0)
+ {
+ // An error occurred, or we have reached the end of the file.
+ // Either way we must exit the loop so we can call the handler.
+ break;
+ }
+
+ // Loop around to try calling sendfile again.
+ }
+ }
+
+ // Pass result back to user's handler.
+ handler_(ec, total_bytes_transferred_);
+ }
+ };
+
+ template <typename Handler>
+ void async_sendfile(tcp::socket& sock, int fd, Handler h)
+ {
+ sendfile_op<Handler> op = { sock, fd, h, 0, 0 };
+ sock.async_write_some(boost::asio::null_buffers(), op);
+ }
+
+
+
+
+
+
+
+[endsect]
+
+
+
+[section:overload3 basic_raw_socket::native_non_blocking (3 of 3 overloads)]
+
+
+['Inherited from basic_socket.]
+
+
+Sets the non-blocking mode of the native socket implementation.
+
+
+ boost::system::error_code native_non_blocking(
+ bool mode,
+ boost::system::error_code & ec);
+
+
+This function is used to modify the non-blocking mode of the underlying native socket. It has no effect on the behaviour of the socket object's synchronous operations.
+
+
+[heading Parameters]
+
+
+[variablelist
+
+[[mode][If `true`, the underlying socket is put into non-blocking mode and direct system calls may fail with `boost::asio::error::would_block` (or the equivalent system error).]]
+
+[[ec][Set to indicate what error occurred, if any. If the `mode` is `false`, but the current value of `non_blocking()` is `true`, this function fails with `boost::asio::error::invalid_argument`, as the combination does not make sense.]]
+
+]
+
+
+[heading Example]
+
+This function is 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 following example illustrates how Linux's `sendfile` system call might be encapsulated:
+
+ template <typename Handler>
+ struct sendfile_op
+ {
+ tcp::socket& sock_;
+ int fd_;
+ Handler handler_;
+ off_t offset_;
+ std::size_t total_bytes_transferred_;
+
+ // Function call operator meeting WriteHandler requirements.
+ // Used as the handler for the async_write_some operation.
+ void operator()(boost::system::error_code ec, std::size_t)
+ {
+ // Put the underlying socket into non-blocking mode.
+ if (!ec)
+ if (!sock_.native_non_blocking())
+ sock_.native_non_blocking(true, ec);
+
+ if (!ec)
+ {
+ for (;;)
+ {
+ // Try the system call.
+ errno = 0;
+ int n = ::sendfile(sock_.native_handle(), fd_, &offset_, 65536);
+ ec = boost::system::error_code(n < 0 ? errno : 0,
+ boost::asio::error::get_system_category());
+ total_bytes_transferred_ += ec ? 0 : n;
+
+ // Retry operation immediately if interrupted by signal.
+ if (ec == boost::asio::error::interrupted)
+ continue;
+
+ // Check if we need to run the operation again.
+ if (ec == boost::asio::error::would_block
+ || ec == boost::asio::error::try_again)
+ {
+ // We have to wait for the socket to become ready again.
+ sock_.async_write_some(boost::asio::null_buffers(), *this);
+ return;
+ }
+
+ if (ec || n == 0)
+ {
+ // An error occurred, or we have reached the end of the file.
+ // Either way we must exit the loop so we can call the handler.
+ break;
+ }
+
+ // Loop around to try calling sendfile again.
+ }
+ }
+
+ // Pass result back to user's handler.
+ handler_(ec, total_bytes_transferred_);
+ }
+ };
+
+ template <typename Handler>
+ void async_sendfile(tcp::socket& sock, int fd, Handler h)
+ {
+ sendfile_op<Handler> op = { sock, fd, h, 0, 0 };
+ sock.async_write_some(boost::asio::null_buffers(), op);
+ }
+
+
+
+
+
+
+
+[endsect]
+
+
+[endsect]
+
+
 [section:native_type basic_raw_socket::native_type]
 
 [indexterm2 native_type..basic_raw_socket]
-The native representation of a socket.
+(Deprecated: Use native\_handle\_type.) The native representation of a socket.
 
 
- typedef RawSocketService::native_type native_type;
+ typedef RawSocketService::native_handle_type native_type;
 
 
 
@@ -11856,6 +13428,142 @@
 [endsect]
 
 
+[section:non_blocking basic_raw_socket::non_blocking]
+
+[indexterm2 non_blocking..basic_raw_socket]
+Gets the non-blocking mode of the socket.
+
+
+ bool ``[link boost_asio.reference.basic_raw_socket.non_blocking.overload1 non_blocking]``() const;
+ `` [''''&raquo;''' [link boost_asio.reference.basic_raw_socket.non_blocking.overload1 more...]]``
+
+
+Sets the non-blocking mode of the socket.
+
+
+ void ``[link boost_asio.reference.basic_raw_socket.non_blocking.overload2 non_blocking]``(
+ bool mode);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_raw_socket.non_blocking.overload2 more...]]``
+
+ boost::system::error_code ``[link boost_asio.reference.basic_raw_socket.non_blocking.overload3 non_blocking]``(
+ bool mode,
+ boost::system::error_code & ec);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_raw_socket.non_blocking.overload3 more...]]``
+
+
+[section:overload1 basic_raw_socket::non_blocking (1 of 3 overloads)]
+
+
+['Inherited from basic_socket.]
+
+
+Gets the non-blocking mode of the socket.
+
+
+ bool non_blocking() const;
+
+
+
+[heading Return Value]
+
+`true` if the socket's synchronous operations will fail with `boost::asio::error::would_block` if they are unable to perform the requested operation immediately. If `false`, synchronous operations will block until complete.
+
+
+[heading Remarks]
+
+The non-blocking mode has no effect on the behaviour of asynchronous operations. Asynchronous operations will never fail with the error `boost::asio::error::would_block`.
+
+
+
+
+[endsect]
+
+
+
+[section:overload2 basic_raw_socket::non_blocking (2 of 3 overloads)]
+
+
+['Inherited from basic_socket.]
+
+
+Sets the non-blocking mode of the socket.
+
+
+ void non_blocking(
+ bool mode);
+
+
+
+[heading Parameters]
+
+
+[variablelist
+
+[[mode][If `true`, the socket's synchronous operations will fail with `boost::asio::error::would_block` if they are unable to perform the requested operation immediately. If `false`, synchronous operations will block until complete.]]
+
+]
+
+
+[heading Exceptions]
+
+
+[variablelist
+
+[[boost::system::system_error][Thrown on failure.]]
+
+]
+
+
+[heading Remarks]
+
+The non-blocking mode has no effect on the behaviour of asynchronous operations. Asynchronous operations will never fail with the error `boost::asio::error::would_block`.
+
+
+
+
+[endsect]
+
+
+
+[section:overload3 basic_raw_socket::non_blocking (3 of 3 overloads)]
+
+
+['Inherited from basic_socket.]
+
+
+Sets the non-blocking mode of the socket.
+
+
+ boost::system::error_code non_blocking(
+ bool mode,
+ boost::system::error_code & ec);
+
+
+
+[heading Parameters]
+
+
+[variablelist
+
+[[mode][If `true`, the socket's synchronous operations will fail with `boost::asio::error::would_block` if they are unable to perform the requested operation immediately. If `false`, synchronous operations will block until complete.]]
+
+[[ec][Set to indicate what error occurred, if any.]]
+
+]
+
+
+[heading Remarks]
+
+The non-blocking mode has no effect on the behaviour of asynchronous operations. Asynchronous operations will never fail with the error `boost::asio::error::would_block`.
+
+
+
+
+[endsect]
+
+
+[endsect]
+
 
 [section:non_blocking_io basic_raw_socket::non_blocking_io]
 
@@ -11863,7 +13571,7 @@
 ['Inherited from socket_base.]
 
 [indexterm2 non_blocking_io..basic_raw_socket]
-IO control command to set the blocking mode of the socket.
+(Deprecated: Use non\_blocking().) IO control command to set the blocking mode of the socket.
 
 
   typedef implementation_defined non_blocking_io;
@@ -13528,17 +15236,17 @@
 
 [endsect]
 
-[section:basic_serial_port basic_serial_port]
+[section:basic_seq_packet_socket basic_seq_packet_socket]
 
 
-Provides serial port functionality.
+Provides sequenced packet socket functionality.
 
 
   template<
- typename ``[link boost_asio.reference.SerialPortService SerialPortService]`` = serial_port_service>
- class basic_serial_port :
- public basic_io_object< SerialPortService >,
- public serial_port_base
+ typename ``[link boost_asio.reference.Protocol Protocol]``,
+ typename ``[link boost_asio.reference.SeqPacketSocketService SeqPacketSocketService]`` = seq_packet_socket_service<Protocol>>
+ class basic_seq_packet_socket :
+ public basic_socket< Protocol, SeqPacketSocketService >
 
 
 [heading Types]
@@ -13547,151 +15255,366 @@
 
   [
 
- [[link boost_asio.reference.basic_serial_port.implementation_type [*implementation_type]]]
+ [[link boost_asio.reference.basic_seq_packet_socket.broadcast [*broadcast]]]
+ [Socket option to permit sending of broadcast messages. ]
+
+ ]
+
+ [
+
+ [[link boost_asio.reference.basic_seq_packet_socket.bytes_readable [*bytes_readable]]]
+ [IO control command to get the amount of data that can be read without blocking. ]
+
+ ]
+
+ [
+
+ [[link boost_asio.reference.basic_seq_packet_socket.debug [*debug]]]
+ [Socket option to enable socket-level debugging. ]
+
+ ]
+
+ [
+
+ [[link boost_asio.reference.basic_seq_packet_socket.do_not_route [*do_not_route]]]
+ [Socket option to prevent routing, use local interfaces only. ]
+
+ ]
+
+ [
+
+ [[link boost_asio.reference.basic_seq_packet_socket.enable_connection_aborted [*enable_connection_aborted]]]
+ [Socket option to report aborted connections on accept. ]
+
+ ]
+
+ [
+
+ [[link boost_asio.reference.basic_seq_packet_socket.endpoint_type [*endpoint_type]]]
+ [The endpoint type. ]
+
+ ]
+
+ [
+
+ [[link boost_asio.reference.basic_seq_packet_socket.implementation_type [*implementation_type]]]
     [The underlying implementation type of I/O object. ]
   
   ]
 
   [
 
- [[link boost_asio.reference.basic_serial_port.lowest_layer_type [*lowest_layer_type]]]
- [A basic_serial_port is always the lowest layer. ]
+ [[link boost_asio.reference.basic_seq_packet_socket.keep_alive [*keep_alive]]]
+ [Socket option to send keep-alives. ]
   
   ]
 
   [
 
- [[link boost_asio.reference.basic_serial_port.native_type [*native_type]]]
- [The native representation of a serial port. ]
+ [[link boost_asio.reference.basic_seq_packet_socket.linger [*linger]]]
+ [Socket option to specify whether the socket lingers on close if unsent data is present. ]
   
   ]
 
   [
 
- [[link boost_asio.reference.basic_serial_port.service_type [*service_type]]]
- [The type of the service that will be used to provide I/O operations. ]
+ [[link boost_asio.reference.basic_seq_packet_socket.lowest_layer_type [*lowest_layer_type]]]
+ [A basic_socket is always the lowest layer. ]
   
   ]
 
-]
+ [
 
-[heading Member Functions]
-[table
- [[Name][Description]]
+ [[link boost_asio.reference.basic_seq_packet_socket.message_flags [*message_flags]]]
+ [Bitmask type for flags that can be passed to send and receive operations. ]
+
+ ]
 
   [
- [[link boost_asio.reference.basic_serial_port.assign [*assign]]]
- [Assign an existing native serial port to the serial port. ]
+
+ [[link boost_asio.reference.basic_seq_packet_socket.native_handle_type [*native_handle_type]]]
+ [The native representation of a socket. ]
+
   ]
+
+ [
+
+ [[link boost_asio.reference.basic_seq_packet_socket.native_type [*native_type]]]
+ [(Deprecated: Use native_handle_type.) The native representation of a socket. ]
   
+ ]
+
   [
- [[link boost_asio.reference.basic_serial_port.async_read_some [*async_read_some]]]
- [Start an asynchronous read. ]
+
+ [[link boost_asio.reference.basic_seq_packet_socket.non_blocking_io [*non_blocking_io]]]
+ [(Deprecated: Use non_blocking().) IO control command to set the blocking mode of the socket. ]
+
   ]
+
+ [
+
+ [[link boost_asio.reference.basic_seq_packet_socket.protocol_type [*protocol_type]]]
+ [The protocol type. ]
   
+ ]
+
   [
- [[link boost_asio.reference.basic_serial_port.async_write_some [*async_write_some]]]
- [Start an asynchronous write. ]
+
+ [[link boost_asio.reference.basic_seq_packet_socket.receive_buffer_size [*receive_buffer_size]]]
+ [Socket option for the receive buffer size of a socket. ]
+
+ ]
+
+ [
+
+ [[link boost_asio.reference.basic_seq_packet_socket.receive_low_watermark [*receive_low_watermark]]]
+ [Socket option for the receive low watermark. ]
+
   ]
+
+ [
+
+ [[link boost_asio.reference.basic_seq_packet_socket.reuse_address [*reuse_address]]]
+ [Socket option to allow the socket to be bound to an address that is already in use. ]
   
+ ]
+
   [
- [[link boost_asio.reference.basic_serial_port.basic_serial_port [*basic_serial_port]]]
- [Construct a basic_serial_port without opening it.
 
- Construct and open a basic_serial_port.
+ [[link boost_asio.reference.basic_seq_packet_socket.send_buffer_size [*send_buffer_size]]]
+ [Socket option for the send buffer size of a socket. ]
+
+ ]
 
- Construct a basic_serial_port on an existing native serial port. ]
+ [
+
+ [[link boost_asio.reference.basic_seq_packet_socket.send_low_watermark [*send_low_watermark]]]
+ [Socket option for the send low watermark. ]
+
   ]
+
+ [
+
+ [[link boost_asio.reference.basic_seq_packet_socket.service_type [*service_type]]]
+ [The type of the service that will be used to provide I/O operations. ]
   
+ ]
+
   [
- [[link boost_asio.reference.basic_serial_port.cancel [*cancel]]]
- [Cancel all asynchronous operations associated with the serial port. ]
+
+ [[link boost_asio.reference.basic_seq_packet_socket.shutdown_type [*shutdown_type]]]
+ [Different ways a socket may be shutdown. ]
+
+ ]
+
+]
+
+[heading Member Functions]
+[table
+ [[Name][Description]]
+
+ [
+ [[link boost_asio.reference.basic_seq_packet_socket.assign [*assign]]]
+ [Assign an existing native socket to the socket. ]
   ]
   
   [
- [[link boost_asio.reference.basic_serial_port.close [*close]]]
- [Close the serial port. ]
+ [[link boost_asio.reference.basic_seq_packet_socket.async_connect [*async_connect]]]
+ [Start an asynchronous connect. ]
   ]
   
   [
- [[link boost_asio.reference.basic_serial_port.get_io_service [*get_io_service]]]
- [Get the io_service associated with the object. ]
+ [[link boost_asio.reference.basic_seq_packet_socket.async_receive [*async_receive]]]
+ [Start an asynchronous receive. ]
   ]
   
   [
- [[link boost_asio.reference.basic_serial_port.get_option [*get_option]]]
- [Get an option from the serial port. ]
+ [[link boost_asio.reference.basic_seq_packet_socket.async_send [*async_send]]]
+ [Start an asynchronous send. ]
   ]
   
   [
- [[link boost_asio.reference.basic_serial_port.io_service [*io_service]]]
- [(Deprecated: use get_io_service().) Get the io_service associated with the object. ]
+ [[link boost_asio.reference.basic_seq_packet_socket.at_mark [*at_mark]]]
+ [Determine whether the socket is at the out-of-band data mark. ]
   ]
   
   [
- [[link boost_asio.reference.basic_serial_port.is_open [*is_open]]]
- [Determine whether the serial port is open. ]
+ [[link boost_asio.reference.basic_seq_packet_socket.available [*available]]]
+ [Determine the number of bytes available for reading. ]
   ]
   
   [
- [[link boost_asio.reference.basic_serial_port.lowest_layer [*lowest_layer]]]
- [Get a reference to the lowest layer.
+ [[link boost_asio.reference.basic_seq_packet_socket.basic_seq_packet_socket [*basic_seq_packet_socket]]]
+ [Construct a basic_seq_packet_socket without opening it.
 
- Get a const reference to the lowest layer. ]
+ Construct and open a basic_seq_packet_socket.
+
+ Construct a basic_seq_packet_socket, opening it and binding it to the given local endpoint.
+
+ Construct a basic_seq_packet_socket on an existing native socket. ]
   ]
   
   [
- [[link boost_asio.reference.basic_serial_port.native [*native]]]
- [Get the native serial port representation. ]
+ [[link boost_asio.reference.basic_seq_packet_socket.bind [*bind]]]
+ [Bind the socket to the given local endpoint. ]
   ]
   
   [
- [[link boost_asio.reference.basic_serial_port.open [*open]]]
- [Open the serial port using the specified device name. ]
+ [[link boost_asio.reference.basic_seq_packet_socket.cancel [*cancel]]]
+ [Cancel all asynchronous operations associated with the socket. ]
   ]
   
   [
- [[link boost_asio.reference.basic_serial_port.read_some [*read_some]]]
- [Read some data from the serial port. ]
+ [[link boost_asio.reference.basic_seq_packet_socket.close [*close]]]
+ [Close the socket. ]
   ]
   
   [
- [[link boost_asio.reference.basic_serial_port.send_break [*send_break]]]
- [Send a break sequence to the serial port. ]
+ [[link boost_asio.reference.basic_seq_packet_socket.connect [*connect]]]
+ [Connect the socket to the specified endpoint. ]
   ]
   
   [
- [[link boost_asio.reference.basic_serial_port.set_option [*set_option]]]
- [Set an option on the serial port. ]
+ [[link boost_asio.reference.basic_seq_packet_socket.get_io_service [*get_io_service]]]
+ [Get the io_service associated with the object. ]
   ]
   
   [
- [[link boost_asio.reference.basic_serial_port.write_some [*write_some]]]
- [Write some data to the serial port. ]
+ [[link boost_asio.reference.basic_seq_packet_socket.get_option [*get_option]]]
+ [Get an option from the socket. ]
   ]
   
-]
-
-[heading Protected Data Members]
-[table
- [[Name][Description]]
-
   [
- [[link boost_asio.reference.basic_serial_port.implementation [*implementation]]]
- [The underlying implementation of the I/O object. ]
+ [[link boost_asio.reference.basic_seq_packet_socket.io_control [*io_control]]]
+ [Perform an IO control command on the socket. ]
   ]
-
+
   [
- [[link boost_asio.reference.basic_serial_port.service [*service]]]
- [The service associated with the I/O object. ]
+ [[link boost_asio.reference.basic_seq_packet_socket.is_open [*is_open]]]
+ [Determine whether the socket is open. ]
   ]
-
-]
-
-The [link boost_asio.reference.basic_serial_port `basic_serial_port`] class template provides functionality that is common to all serial ports.
-
-
-[heading Thread Safety]
+
+ [
+ [[link boost_asio.reference.basic_seq_packet_socket.local_endpoint [*local_endpoint]]]
+ [Get the local endpoint of the socket. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_seq_packet_socket.lowest_layer [*lowest_layer]]]
+ [Get a reference to the lowest layer.
+
+ Get a const reference to the lowest layer. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_seq_packet_socket.native [*native]]]
+ [(Deprecated: Use native_handle().) Get the native socket representation. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_seq_packet_socket.native_handle [*native_handle]]]
+ [Get the native socket representation. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_seq_packet_socket.native_non_blocking [*native_non_blocking]]]
+ [Gets the non-blocking mode of the native socket implementation.
+
+ Sets the non-blocking mode of the native socket implementation. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_seq_packet_socket.non_blocking [*non_blocking]]]
+ [Gets the non-blocking mode of the socket.
+
+ Sets the non-blocking mode of the socket. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_seq_packet_socket.open [*open]]]
+ [Open the socket using the specified protocol. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_seq_packet_socket.receive [*receive]]]
+ [Receive some data on the socket.
+
+ Receive some data on a connected socket. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_seq_packet_socket.remote_endpoint [*remote_endpoint]]]
+ [Get the remote endpoint of the socket. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_seq_packet_socket.send [*send]]]
+ [Send some data on the socket. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_seq_packet_socket.set_option [*set_option]]]
+ [Set an option on the socket. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_seq_packet_socket.shutdown [*shutdown]]]
+ [Disable sends or receives on the socket. ]
+ ]
+
+]
+
+[heading Data Members]
+[table
+ [[Name][Description]]
+
+ [
+ [[link boost_asio.reference.basic_seq_packet_socket.max_connections [*max_connections]]]
+ [The maximum length of the queue of pending incoming connections. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_seq_packet_socket.message_do_not_route [*message_do_not_route]]]
+ [Specify that the data should not be subject to routing. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_seq_packet_socket.message_end_of_record [*message_end_of_record]]]
+ [Specifies that the data marks the end of a record. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_seq_packet_socket.message_out_of_band [*message_out_of_band]]]
+ [Process out-of-band data. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_seq_packet_socket.message_peek [*message_peek]]]
+ [Peek at incoming data without removing it from the input queue. ]
+ ]
+
+]
+
+[heading Protected Data Members]
+[table
+ [[Name][Description]]
+
+ [
+ [[link boost_asio.reference.basic_seq_packet_socket.implementation [*implementation]]]
+ [The underlying implementation of the I/O object. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_seq_packet_socket.service [*service]]]
+ [The service associated with the I/O object. ]
+ ]
+
+]
+
+The [link boost_asio.reference.basic_seq_packet_socket `basic_seq_packet_socket`] class template provides asynchronous and blocking sequenced packet socket functionality.
+
+
+[heading Thread Safety]
   
 [*Distinct] [*objects:] Safe.
 
@@ -13701,34 +15624,40 @@
 
 [heading Requirements]
 
-[*Header: ][^boost/asio/basic_serial_port.hpp]
+[*Header: ][^boost/asio/basic_seq_packet_socket.hpp]
 
 [*Convenience header: ][^boost/asio.hpp]
 
-[section:assign basic_serial_port::assign]
+[section:assign basic_seq_packet_socket::assign]
 
-[indexterm2 assign..basic_serial_port]
-Assign an existing native serial port to the serial port.
+[indexterm2 assign..basic_seq_packet_socket]
+Assign an existing native socket to the socket.
 
 
- void ``[link boost_asio.reference.basic_serial_port.assign.overload1 assign]``(
- const native_type & native_serial_port);
- `` [''''&raquo;''' [link boost_asio.reference.basic_serial_port.assign.overload1 more...]]``
+ void ``[link boost_asio.reference.basic_seq_packet_socket.assign.overload1 assign]``(
+ const protocol_type & protocol,
+ const native_handle_type & native_socket);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.assign.overload1 more...]]``
 
- boost::system::error_code ``[link boost_asio.reference.basic_serial_port.assign.overload2 assign]``(
- const native_type & native_serial_port,
+ boost::system::error_code ``[link boost_asio.reference.basic_seq_packet_socket.assign.overload2 assign]``(
+ const protocol_type & protocol,
+ const native_handle_type & native_socket,
       boost::system::error_code & ec);
- `` [''''&raquo;''' [link boost_asio.reference.basic_serial_port.assign.overload2 more...]]``
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.assign.overload2 more...]]``
 
 
-[section:overload1 basic_serial_port::assign (1 of 2 overloads)]
+[section:overload1 basic_seq_packet_socket::assign (1 of 2 overloads)]
 
 
-Assign an existing native serial port to the serial port.
+['Inherited from basic_socket.]
+
+
+Assign an existing native socket to the socket.
 
 
   void assign(
- const native_type & native_serial_port);
+ const protocol_type & protocol,
+ const native_handle_type & native_socket);
 
 
 
@@ -13736,14 +15665,18 @@
 
 
 
-[section:overload2 basic_serial_port::assign (2 of 2 overloads)]
+[section:overload2 basic_seq_packet_socket::assign (2 of 2 overloads)]
 
 
-Assign an existing native serial port to the serial port.
+['Inherited from basic_socket.]
+
+
+Assign an existing native socket to the socket.
 
 
   boost::system::error_code assign(
- const native_type & native_serial_port,
+ const protocol_type & protocol,
+ const native_handle_type & native_socket,
       boost::system::error_code & ec);
 
 
@@ -13754,21 +15687,25 @@
 [endsect]
 
 
-[section:async_read_some basic_serial_port::async_read_some]
+[section:async_connect basic_seq_packet_socket::async_connect]
 
-[indexterm2 async_read_some..basic_serial_port]
-Start an asynchronous read.
+
+['Inherited from basic_socket.]
+
+[indexterm2 async_connect..basic_seq_packet_socket]
+Start an asynchronous connect.
 
 
   template<
- typename ``[link boost_asio.reference.MutableBufferSequence MutableBufferSequence]``,
- typename ``[link boost_asio.reference.ReadHandler ReadHandler]``>
- void async_read_some(
- const MutableBufferSequence & buffers,
- ReadHandler handler);
+ typename ``[link boost_asio.reference.ConnectHandler ConnectHandler]``>
+ void async_connect(
+ const endpoint_type & peer_endpoint,
+ ConnectHandler handler);
 
 
-This function is used to asynchronously read data from the serial port. The function call always returns immediately.
+This function is used to asynchronously connect a socket to the specified remote endpoint. The function call always returns immediately.
+
+The socket is automatically opened if it is not already open. If the connect fails, and the socket was automatically opened, the socket is not returned to the closed state.
 
 
 [heading Parameters]
@@ -13776,13 +15713,12 @@
 
 [variablelist
   
-[[buffers][One or more buffers into which the data will be read. Although the buffers object may be copied as necessary, ownership of the underlying memory blocks is retained by the caller, which must guarantee that they remain valid until the handler is called.]]
+[[peer_endpoint][The remote endpoint to which the socket will be connected. Copies will be made of the endpoint object as required.]]
 
-[[handler][The handler to be called when the read operation completes. Copies will be made of the handler as required. The function signature of the handler must be:
+[[handler][The handler to be called when the connection operation completes. Copies will be made of the handler as required. The function signature of the handler must be:
 ``
    void handler(
- const boost::system::error_code& error, // Result of operation.
- std::size_t bytes_transferred // Number of bytes read.
+ const boost::system::error_code& error // Result of operation
    );
 ``
 Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using `boost::asio::io_service::post()`.]]
@@ -13790,19 +15726,27 @@
 ]
 
 
-[heading Remarks]
-
-The read operation may not read all of the requested number of bytes. Consider using the [link boost_asio.reference.async_read `async_read`] function if you need to ensure that the requested amount of data is read before the asynchronous operation completes.
-
-
 [heading Example]
   
-To read into a single data buffer use the [link boost_asio.reference.buffer `buffer`] function as follows:
 
- serial_port.async_read_some(boost::asio::buffer(data, size), handler);
+
+ void connect_handler(const boost::system::error_code& error)
+ {
+ if (!error)
+ {
+ // Connect succeeded.
+ }
+ }
+
+ ...
+
+ boost::asio::ip::tcp::socket socket(io_service);
+ boost::asio::ip::tcp::endpoint endpoint(
+ boost::asio::ip::address::from_string("1.2.3.4"), 12345);
+ socket.async_connect(endpoint, connect_handler);
+
 
 
-See the [link boost_asio.reference.buffer `buffer`] documentation for information on reading into multiple buffers in one go, and how to use it with arrays, boost::array or std::vector.
 
 
 
@@ -13810,22 +15754,48 @@
 [endsect]
 
 
+[section:async_receive basic_seq_packet_socket::async_receive]
 
-[section:async_write_some basic_serial_port::async_write_some]
+[indexterm2 async_receive..basic_seq_packet_socket]
+Start an asynchronous receive.
 
-[indexterm2 async_write_some..basic_serial_port]
-Start an asynchronous write.
 
+ template<
+ typename ``[link boost_asio.reference.MutableBufferSequence MutableBufferSequence]``,
+ typename ``[link boost_asio.reference.ReadHandler ReadHandler]``>
+ void ``[link boost_asio.reference.basic_seq_packet_socket.async_receive.overload1 async_receive]``(
+ const MutableBufferSequence & buffers,
+ socket_base::message_flags & out_flags,
+ ReadHandler handler);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.async_receive.overload1 more...]]``
 
   template<
- typename ``[link boost_asio.reference.ConstBufferSequence ConstBufferSequence]``,
- typename ``[link boost_asio.reference.WriteHandler WriteHandler]``>
- void async_write_some(
- const ConstBufferSequence & buffers,
- WriteHandler handler);
+ typename ``[link boost_asio.reference.MutableBufferSequence MutableBufferSequence]``,
+ typename ``[link boost_asio.reference.ReadHandler ReadHandler]``>
+ void ``[link boost_asio.reference.basic_seq_packet_socket.async_receive.overload2 async_receive]``(
+ const MutableBufferSequence & buffers,
+ socket_base::message_flags in_flags,
+ socket_base::message_flags & out_flags,
+ ReadHandler handler);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.async_receive.overload2 more...]]``
 
 
-This function is used to asynchronously write data to the serial port. The function call always returns immediately.
+[section:overload1 basic_seq_packet_socket::async_receive (1 of 2 overloads)]
+
+
+Start an asynchronous receive.
+
+
+ template<
+ typename ``[link boost_asio.reference.MutableBufferSequence MutableBufferSequence]``,
+ typename ``[link boost_asio.reference.ReadHandler ReadHandler]``>
+ void async_receive(
+ const MutableBufferSequence & buffers,
+ socket_base::message_flags & out_flags,
+ ReadHandler handler);
+
+
+This function is used to asynchronously receive data from the sequenced packet socket. The function call always returns immediately.
 
 
 [heading Parameters]
@@ -13833,13 +15803,15 @@
 
 [variablelist
   
-[[buffers][One or more data buffers to be written to the serial port. Although the buffers object may be copied as necessary, ownership of the underlying memory blocks is retained by the caller, which must guarantee that they remain valid until the handler is called.]]
+[[buffers][One or more buffers into which the data will be received. Although the buffers object may be copied as necessary, ownership of the underlying memory blocks is retained by the caller, which must guarantee that they remain valid until the handler is called.]]
 
-[[handler][The handler to be called when the write operation completes. Copies will be made of the handler as required. The function signature of the handler must be:
+[[out_flags][Once the asynchronous operation completes, contains flags associated with the received data. For example, if the `socket_base::message_end_of_record` bit is set then the received data marks the end of a record. The caller must guarantee that the referenced variable remains valid until the handler is called.]]
+
+[[handler][The handler to be called when the receive operation completes. Copies will be made of the handler as required. The function signature of the handler must be:
 ``
    void handler(
      const boost::system::error_code& error, // Result of operation.
- std::size_t bytes_transferred // Number of bytes written.
+ std::size_t bytes_transferred // Number of bytes received.
    );
 ``
 Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using `boost::asio::io_service::post()`.]]
@@ -13847,19 +15819,14 @@
 ]
 
 
-[heading Remarks]
-
-The write operation may not transmit all of the data to the peer. Consider using the [link boost_asio.reference.async_write `async_write`] function if you need to ensure that all data is written before the asynchronous operation completes.
-
-
 [heading Example]
   
-To write a single data buffer use the [link boost_asio.reference.buffer `buffer`] function as follows:
+To receive into a single data buffer use the [link boost_asio.reference.buffer `buffer`] function as follows:
 
- serial_port.async_write_some(boost::asio::buffer(data, size), handler);
+ socket.async_receive(boost::asio::buffer(data, size), out_flags, handler);
 
 
-See the [link boost_asio.reference.buffer `buffer`] documentation for information on writing multiple buffers in one go, and how to use it with arrays, boost::array or std::vector.
+See the [link boost_asio.reference.buffer `buffer`] documentation for information on receiving into multiple buffers in one go, and how to use it with arrays, boost::array or std::vector.
 
 
 
@@ -13867,61 +15834,59 @@
 [endsect]
 
 
-[section:basic_serial_port basic_serial_port::basic_serial_port]
-
-[indexterm2 basic_serial_port..basic_serial_port]
-Construct a [link boost_asio.reference.basic_serial_port `basic_serial_port`] without opening it.
-
-
- explicit ``[link boost_asio.reference.basic_serial_port.basic_serial_port.overload1 basic_serial_port]``(
- boost::asio::io_service & io_service);
- `` [''''&raquo;''' [link boost_asio.reference.basic_serial_port.basic_serial_port.overload1 more...]]``
-
-
-Construct and open a [link boost_asio.reference.basic_serial_port `basic_serial_port`].
 
+[section:overload2 basic_seq_packet_socket::async_receive (2 of 2 overloads)]
 
- explicit ``[link boost_asio.reference.basic_serial_port.basic_serial_port.overload2 basic_serial_port]``(
- boost::asio::io_service & io_service,
- const char * device);
- `` [''''&raquo;''' [link boost_asio.reference.basic_serial_port.basic_serial_port.overload2 more...]]``
 
- explicit ``[link boost_asio.reference.basic_serial_port.basic_serial_port.overload3 basic_serial_port]``(
- boost::asio::io_service & io_service,
- const std::string & device);
- `` [''''&raquo;''' [link boost_asio.reference.basic_serial_port.basic_serial_port.overload3 more...]]``
+Start an asynchronous receive.
 
 
-Construct a [link boost_asio.reference.basic_serial_port `basic_serial_port`] on an existing native serial port.
+ template<
+ typename ``[link boost_asio.reference.MutableBufferSequence MutableBufferSequence]``,
+ typename ``[link boost_asio.reference.ReadHandler ReadHandler]``>
+ void async_receive(
+ const MutableBufferSequence & buffers,
+ socket_base::message_flags in_flags,
+ socket_base::message_flags & out_flags,
+ ReadHandler handler);
 
 
- ``[link boost_asio.reference.basic_serial_port.basic_serial_port.overload4 basic_serial_port]``(
- boost::asio::io_service & io_service,
- const native_type & native_serial_port);
- `` [''''&raquo;''' [link boost_asio.reference.basic_serial_port.basic_serial_port.overload4 more...]]``
+This function is used to asynchronously receive data from the sequenced data socket. The function call always returns immediately.
 
 
-[section:overload1 basic_serial_port::basic_serial_port (1 of 4 overloads)]
+[heading Parameters]
+
 
+[variablelist
+
+[[buffers][One or more buffers into which the data will be received. Although the buffers object may be copied as necessary, ownership of the underlying memory blocks is retained by the caller, which must guarantee that they remain valid until the handler is called.]]
 
-Construct a [link boost_asio.reference.basic_serial_port `basic_serial_port`] without opening it.
+[[in_flags][Flags specifying how the receive call is to be made.]]
 
+[[out_flags][Once the asynchronous operation completes, contains flags associated with the received data. For example, if the `socket_base::message_end_of_record` bit is set then the received data marks the end of a record. The caller must guarantee that the referenced variable remains valid until the handler is called.]]
 
- basic_serial_port(
- boost::asio::io_service & io_service);
+[[handler][The handler to be called when the receive operation completes. Copies will be made of the handler as required. The function signature of the handler must be:
+``
+ void handler(
+ const boost::system::error_code& error, // Result of operation.
+ std::size_t bytes_transferred // Number of bytes received.
+ );
+``
+Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using `boost::asio::io_service::post()`.]]
 
+]
 
-This constructor creates a serial port without opening it.
 
+[heading Example]
+
+To receive into a single data buffer use the [link boost_asio.reference.buffer `buffer`] function as follows:
 
-[heading Parameters]
-
+ socket.async_receive(
+ boost::asio::buffer(data, size),
+ 0, out_flags, handler);
 
-[variablelist
-
-[[io_service][The [link boost_asio.reference.io_service `io_service`] object that the serial port will use to dispatch handlers for any asynchronous operations performed on the port. ]]
 
-]
+See the [link boost_asio.reference.buffer `buffer`] documentation for information on receiving into multiple buffers in one go, and how to use it with arrays, boost::array or std::vector.
 
 
 
@@ -13929,19 +15894,25 @@
 [endsect]
 
 
+[endsect]
 
-[section:overload2 basic_serial_port::basic_serial_port (2 of 4 overloads)]
 
+[section:async_send basic_seq_packet_socket::async_send]
 
-Construct and open a [link boost_asio.reference.basic_serial_port `basic_serial_port`].
+[indexterm2 async_send..basic_seq_packet_socket]
+Start an asynchronous send.
 
 
- basic_serial_port(
- boost::asio::io_service & io_service,
- const char * device);
+ template<
+ typename ``[link boost_asio.reference.ConstBufferSequence ConstBufferSequence]``,
+ typename ``[link boost_asio.reference.WriteHandler WriteHandler]``>
+ void async_send(
+ const ConstBufferSequence & buffers,
+ socket_base::message_flags flags,
+ WriteHandler handler);
 
 
-This constructor creates and opens a serial port for the specified device name.
+This function is used to asynchronously send data on the sequenced packet socket. The function call always returns immediately.
 
 
 [heading Parameters]
@@ -13949,41 +15920,77 @@
 
 [variablelist
   
-[[io_service][The [link boost_asio.reference.io_service `io_service`] object that the serial port will use to dispatch handlers for any asynchronous operations performed on the port.]]
+[[buffers][One or more data buffers to be sent on the socket. Although the buffers object may be copied as necessary, ownership of the underlying memory blocks is retained by the caller, which must guarantee that they remain valid until the handler is called.]]
 
-[[device][The platform-specific device name for this serial port. ]]
+[[flags][Flags specifying how the send call is to be made.]]
+
+[[handler][The handler to be called when the send operation completes. Copies will be made of the handler as required. The function signature of the handler must be:
+``
+ void handler(
+ const boost::system::error_code& error, // Result of operation.
+ std::size_t bytes_transferred // Number of bytes sent.
+ );
+``
+Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using `boost::asio::io_service::post()`.]]
 
 ]
 
 
+[heading Example]
+
+To send a single data buffer use the [link boost_asio.reference.buffer `buffer`] function as follows:
+
+ socket.async_send(boost::asio::buffer(data, size), 0, handler);
+
+
+See the [link boost_asio.reference.buffer `buffer`] documentation for information on sending multiple buffers in one go, and how to use it with arrays, boost::array or std::vector.
+
+
 
 
 [endsect]
 
 
+[section:at_mark basic_seq_packet_socket::at_mark]
 
-[section:overload3 basic_serial_port::basic_serial_port (3 of 4 overloads)]
+[indexterm2 at_mark..basic_seq_packet_socket]
+Determine whether the socket is at the out-of-band data mark.
 
 
-Construct and open a [link boost_asio.reference.basic_serial_port `basic_serial_port`].
+ bool ``[link boost_asio.reference.basic_seq_packet_socket.at_mark.overload1 at_mark]``() const;
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.at_mark.overload1 more...]]``
 
+ bool ``[link boost_asio.reference.basic_seq_packet_socket.at_mark.overload2 at_mark]``(
+ boost::system::error_code & ec) const;
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.at_mark.overload2 more...]]``
 
- basic_serial_port(
- boost::asio::io_service & io_service,
- const std::string & device);
 
+[section:overload1 basic_seq_packet_socket::at_mark (1 of 2 overloads)]
 
-This constructor creates and opens a serial port for the specified device name.
 
+['Inherited from basic_socket.]
 
-[heading Parameters]
+
+Determine whether the socket is at the out-of-band data mark.
+
+
+ bool at_mark() const;
+
+
+This function is used to check whether the socket input is currently positioned at the out-of-band data mark.
+
+
+[heading Return Value]
+
+A bool indicating whether the socket is at the out-of-band data mark.
+
+
+[heading Exceptions]
     
 
 [variablelist
   
-[[io_service][The [link boost_asio.reference.io_service `io_service`] object that the serial port will use to dispatch handlers for any asynchronous operations performed on the port.]]
-
-[[device][The platform-specific device name for this serial port. ]]
+[[boost::system::system_error][Thrown on failure. ]]
 
 ]
 
@@ -13994,18 +16001,20 @@
 
 
 
-[section:overload4 basic_serial_port::basic_serial_port (4 of 4 overloads)]
+[section:overload2 basic_seq_packet_socket::at_mark (2 of 2 overloads)]
 
 
-Construct a [link boost_asio.reference.basic_serial_port `basic_serial_port`] on an existing native serial port.
+['Inherited from basic_socket.]
 
 
- basic_serial_port(
- boost::asio::io_service & io_service,
- const native_type & native_serial_port);
+Determine whether the socket is at the out-of-band data mark.
 
 
-This constructor creates a serial port object to hold an existing native serial port.
+ bool at_mark(
+ boost::system::error_code & ec) const;
+
+
+This function is used to check whether the socket input is currently positioned at the out-of-band data mark.
 
 
 [heading Parameters]
@@ -14013,54 +16022,55 @@
 
 [variablelist
   
-[[io_service][The [link boost_asio.reference.io_service `io_service`] object that the serial port will use to dispatch handlers for any asynchronous operations performed on the port.]]
-
-[[native_serial_port][A native serial port.]]
+[[ec][Set to indicate what error occurred, if any.]]
 
 ]
 
 
-[heading Exceptions]
-
+[heading Return Value]
+
+A bool indicating whether the socket is at the out-of-band data mark.
 
-[variablelist
-
-[[boost::system::system_error][Thrown on failure. ]]
 
-]
 
 
+[endsect]
 
 
 [endsect]
 
+[section:available basic_seq_packet_socket::available]
 
-[endsect]
+[indexterm2 available..basic_seq_packet_socket]
+Determine the number of bytes available for reading.
 
-[section:cancel basic_serial_port::cancel]
 
-[indexterm2 cancel..basic_serial_port]
-Cancel all asynchronous operations associated with the serial port.
+ std::size_t ``[link boost_asio.reference.basic_seq_packet_socket.available.overload1 available]``() const;
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.available.overload1 more...]]``
 
+ std::size_t ``[link boost_asio.reference.basic_seq_packet_socket.available.overload2 available]``(
+ boost::system::error_code & ec) const;
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.available.overload2 more...]]``
 
- void ``[link boost_asio.reference.basic_serial_port.cancel.overload1 cancel]``();
- `` [''''&raquo;''' [link boost_asio.reference.basic_serial_port.cancel.overload1 more...]]``
 
- boost::system::error_code ``[link boost_asio.reference.basic_serial_port.cancel.overload2 cancel]``(
- boost::system::error_code & ec);
- `` [''''&raquo;''' [link boost_asio.reference.basic_serial_port.cancel.overload2 more...]]``
+[section:overload1 basic_seq_packet_socket::available (1 of 2 overloads)]
 
 
-[section:overload1 basic_serial_port::cancel (1 of 2 overloads)]
+['Inherited from basic_socket.]
 
 
-Cancel all asynchronous operations associated with the serial port.
+Determine the number of bytes available for reading.
 
 
- void cancel();
+ std::size_t available() const;
 
 
-This function causes all outstanding asynchronous read or write operations to finish immediately, and the handlers for cancelled operations will be passed the `boost::asio::error::operation_aborted` error.
+This function is used to determine the number of bytes that may be read without blocking.
+
+
+[heading Return Value]
+
+The number of bytes that may be read without blocking, or 0 if an error occurs.
 
 
 [heading Exceptions]
@@ -14079,17 +16089,20 @@
 
 
 
-[section:overload2 basic_serial_port::cancel (2 of 2 overloads)]
+[section:overload2 basic_seq_packet_socket::available (2 of 2 overloads)]
 
 
-Cancel all asynchronous operations associated with the serial port.
+['Inherited from basic_socket.]
 
 
- boost::system::error_code cancel(
- boost::system::error_code & ec);
+Determine the number of bytes available for reading.
 
 
-This function causes all outstanding asynchronous read or write operations to finish immediately, and the handlers for cancelled operations will be passed the `boost::asio::error::operation_aborted` error.
+ std::size_t available(
+ boost::system::error_code & ec) const;
+
+
+This function is used to determine the number of bytes that may be read without blocking.
 
 
 [heading Parameters]
@@ -14097,71 +16110,73 @@
 
 [variablelist
   
-[[ec][Set to indicate what error occurred, if any. ]]
+[[ec][Set to indicate what error occurred, if any.]]
 
 ]
 
 
+[heading Return Value]
+
+The number of bytes that may be read without blocking, or 0 if an error occurs.
 
 
-[endsect]
 
 
 [endsect]
 
-[section:close basic_serial_port::close]
-
-[indexterm2 close..basic_serial_port]
-Close the serial port.
-
-
- void ``[link boost_asio.reference.basic_serial_port.close.overload1 close]``();
- `` [''''&raquo;''' [link boost_asio.reference.basic_serial_port.close.overload1 more...]]``
-
- boost::system::error_code ``[link boost_asio.reference.basic_serial_port.close.overload2 close]``(
- boost::system::error_code & ec);
- `` [''''&raquo;''' [link boost_asio.reference.basic_serial_port.close.overload2 more...]]``
 
+[endsect]
 
-[section:overload1 basic_serial_port::close (1 of 2 overloads)]
+[section:basic_seq_packet_socket basic_seq_packet_socket::basic_seq_packet_socket]
 
+[indexterm2 basic_seq_packet_socket..basic_seq_packet_socket]
+Construct a [link boost_asio.reference.basic_seq_packet_socket `basic_seq_packet_socket`] without opening it.
 
-Close the serial port.
 
+ explicit ``[link boost_asio.reference.basic_seq_packet_socket.basic_seq_packet_socket.overload1 basic_seq_packet_socket]``(
+ boost::asio::io_service & io_service);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.basic_seq_packet_socket.overload1 more...]]``
 
- void close();
 
+Construct and open a [link boost_asio.reference.basic_seq_packet_socket `basic_seq_packet_socket`].
 
-This function is used to close the serial port. Any asynchronous read or write operations will be cancelled immediately, and will complete with the `boost::asio::error::operation_aborted` error.
 
+ ``[link boost_asio.reference.basic_seq_packet_socket.basic_seq_packet_socket.overload2 basic_seq_packet_socket]``(
+ boost::asio::io_service & io_service,
+ const protocol_type & protocol);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.basic_seq_packet_socket.overload2 more...]]``
 
-[heading Exceptions]
-
 
-[variablelist
-
-[[boost::system::system_error][Thrown on failure. ]]
+Construct a [link boost_asio.reference.basic_seq_packet_socket `basic_seq_packet_socket`], opening it and binding it to the given local endpoint.
 
-]
 
+ ``[link boost_asio.reference.basic_seq_packet_socket.basic_seq_packet_socket.overload3 basic_seq_packet_socket]``(
+ boost::asio::io_service & io_service,
+ const endpoint_type & endpoint);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.basic_seq_packet_socket.overload3 more...]]``
 
 
+Construct a [link boost_asio.reference.basic_seq_packet_socket `basic_seq_packet_socket`] on an existing native socket.
 
-[endsect]
 
+ ``[link boost_asio.reference.basic_seq_packet_socket.basic_seq_packet_socket.overload4 basic_seq_packet_socket]``(
+ boost::asio::io_service & io_service,
+ const protocol_type & protocol,
+ const native_handle_type & native_socket);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.basic_seq_packet_socket.overload4 more...]]``
 
 
-[section:overload2 basic_serial_port::close (2 of 2 overloads)]
+[section:overload1 basic_seq_packet_socket::basic_seq_packet_socket (1 of 4 overloads)]
 
 
-Close the serial port.
+Construct a [link boost_asio.reference.basic_seq_packet_socket `basic_seq_packet_socket`] without opening it.
 
 
- boost::system::error_code close(
- boost::system::error_code & ec);
+ basic_seq_packet_socket(
+ boost::asio::io_service & io_service);
 
 
-This function is used to close the serial port. Any asynchronous read or write operations will be cancelled immediately, and will complete with the `boost::asio::error::operation_aborted` error.
+This constructor creates a sequenced packet socket without opening it. The socket needs to be opened and then connected or accepted before data can be sent or received on it.
 
 
 [heading Parameters]
@@ -14169,7 +16184,7 @@
 
 [variablelist
   
-[[ec][Set to indicate what error occurred, if any. ]]
+[[io_service][The [link boost_asio.reference.io_service `io_service`] object that the sequenced packet socket will use to dispatch handlers for any asynchronous operations performed on the socket. ]]
 
 ]
 
@@ -14179,67 +16194,61 @@
 [endsect]
 
 
-[endsect]
 
+[section:overload2 basic_seq_packet_socket::basic_seq_packet_socket (2 of 4 overloads)]
 
-[section:get_io_service basic_serial_port::get_io_service]
 
+Construct and open a [link boost_asio.reference.basic_seq_packet_socket `basic_seq_packet_socket`].
 
-['Inherited from basic_io_object.]
 
-[indexterm2 get_io_service..basic_serial_port]
-Get the [link boost_asio.reference.io_service `io_service`] associated with the object.
+ basic_seq_packet_socket(
+ boost::asio::io_service & io_service,
+ const protocol_type & protocol);
 
 
- boost::asio::io_service & get_io_service();
+This constructor creates and opens a sequenced\_packet socket. The socket needs to be connected or accepted before data can be sent or received on it.
 
 
-This function may be used to obtain the [link boost_asio.reference.io_service `io_service`] object that the I/O object uses to dispatch handlers for asynchronous operations.
+[heading Parameters]
+
 
+[variablelist
+
+[[io_service][The [link boost_asio.reference.io_service `io_service`] object that the sequenced packet socket will use to dispatch handlers for any asynchronous operations performed on the socket.]]
 
-[heading Return Value]
-
-A reference to the [link boost_asio.reference.io_service `io_service`] object that the I/O object will use to dispatch handlers. Ownership is not transferred to the caller.
+[[protocol][An object specifying protocol parameters to be used.]]
 
+]
 
 
+[heading Exceptions]
+
 
-[endsect]
+[variablelist
+
+[[boost::system::system_error][Thrown on failure. ]]
 
+]
 
-[section:get_option basic_serial_port::get_option]
 
-[indexterm2 get_option..basic_serial_port]
-Get an option from the serial port.
 
 
- template<
- typename ``[link boost_asio.reference.GettableSerialPortOption GettableSerialPortOption]``>
- void ``[link boost_asio.reference.basic_serial_port.get_option.overload1 get_option]``(
- GettableSerialPortOption & option);
- `` [''''&raquo;''' [link boost_asio.reference.basic_serial_port.get_option.overload1 more...]]``
+[endsect]
 
- template<
- typename ``[link boost_asio.reference.GettableSerialPortOption GettableSerialPortOption]``>
- boost::system::error_code ``[link boost_asio.reference.basic_serial_port.get_option.overload2 get_option]``(
- GettableSerialPortOption & option,
- boost::system::error_code & ec);
- `` [''''&raquo;''' [link boost_asio.reference.basic_serial_port.get_option.overload2 more...]]``
 
 
-[section:overload1 basic_serial_port::get_option (1 of 2 overloads)]
+[section:overload3 basic_seq_packet_socket::basic_seq_packet_socket (3 of 4 overloads)]
 
 
-Get an option from the serial port.
+Construct a [link boost_asio.reference.basic_seq_packet_socket `basic_seq_packet_socket`], opening it and binding it to the given local endpoint.
 
 
- template<
- typename ``[link boost_asio.reference.GettableSerialPortOption GettableSerialPortOption]``>
- void get_option(
- GettableSerialPortOption & option);
+ basic_seq_packet_socket(
+ boost::asio::io_service & io_service,
+ const endpoint_type & endpoint);
 
 
-This function is used to get the current value of an option on the serial port.
+This constructor creates a sequenced packet socket and automatically opens it bound to the specified endpoint on the local machine. The protocol used is the protocol associated with the given endpoint.
 
 
 [heading Parameters]
@@ -14247,7 +16256,9 @@
 
 [variablelist
   
-[[option][The option value to be obtained from the serial port.]]
+[[io_service][The [link boost_asio.reference.io_service `io_service`] object that the sequenced packet socket will use to dispatch handlers for any asynchronous operations performed on the socket.]]
+
+[[endpoint][An endpoint on the local machine to which the sequenced packet socket will be bound.]]
 
 ]
 
@@ -14257,32 +16268,30 @@
 
 [variablelist
   
-[[boost::system::system_error][Thrown on failure.]]
+[[boost::system::system_error][Thrown on failure. ]]
 
 ]
 
 
 
 
-
 [endsect]
 
 
 
-[section:overload2 basic_serial_port::get_option (2 of 2 overloads)]
+[section:overload4 basic_seq_packet_socket::basic_seq_packet_socket (4 of 4 overloads)]
 
 
-Get an option from the serial port.
+Construct a [link boost_asio.reference.basic_seq_packet_socket `basic_seq_packet_socket`] on an existing native socket.
 
 
- template<
- typename ``[link boost_asio.reference.GettableSerialPortOption GettableSerialPortOption]``>
- boost::system::error_code get_option(
- GettableSerialPortOption & option,
- boost::system::error_code & ec);
+ basic_seq_packet_socket(
+ boost::asio::io_service & io_service,
+ const protocol_type & protocol,
+ const native_handle_type & native_socket);
 
 
-This function is used to get the current value of an option on the serial port.
+This constructor creates a sequenced packet socket object to hold an existing native socket.
 
 
 [heading Parameters]
@@ -14290,463 +16299,363 @@
 
 [variablelist
   
-[[option][The option value to be obtained from the serial port.]]
+[[io_service][The [link boost_asio.reference.io_service `io_service`] object that the sequenced packet socket will use to dispatch handlers for any asynchronous operations performed on the socket.]]
 
-[[ec][Set to indicate what error occured, if any.]]
+[[protocol][An object specifying protocol parameters to be used.]]
 
-]
+[[native_socket][The new underlying socket implementation.]]
 
+]
 
 
+[heading Exceptions]
+
 
+[variablelist
+
+[[boost::system::system_error][Thrown on failure. ]]
 
-[endsect]
+]
 
 
-[endsect]
 
 
-[section:implementation basic_serial_port::implementation]
+[endsect]
 
 
-['Inherited from basic_io_object.]
+[endsect]
 
-[indexterm2 implementation..basic_serial_port]
-The underlying implementation of the I/O object.
+[section:bind basic_seq_packet_socket::bind]
 
+[indexterm2 bind..basic_seq_packet_socket]
+Bind the socket to the given local endpoint.
 
- implementation_type implementation;
 
+ void ``[link boost_asio.reference.basic_seq_packet_socket.bind.overload1 bind]``(
+ const endpoint_type & endpoint);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.bind.overload1 more...]]``
 
+ boost::system::error_code ``[link boost_asio.reference.basic_seq_packet_socket.bind.overload2 bind]``(
+ const endpoint_type & endpoint,
+ boost::system::error_code & ec);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.bind.overload2 more...]]``
 
-[endsect]
 
+[section:overload1 basic_seq_packet_socket::bind (1 of 2 overloads)]
 
 
-[section:implementation_type basic_serial_port::implementation_type]
+['Inherited from basic_socket.]
 
 
-['Inherited from basic_io_object.]
+Bind the socket to the given local endpoint.
 
-[indexterm2 implementation_type..basic_serial_port]
-The underlying implementation type of I/O object.
 
+ void bind(
+ const endpoint_type & endpoint);
 
- typedef service_type::implementation_type implementation_type;
 
+This function binds the socket to the specified endpoint on the local machine.
 
 
-[heading Requirements]
+[heading Parameters]
+
 
-[*Header: ][^boost/asio/basic_serial_port.hpp]
+[variablelist
+
+[[endpoint][An endpoint on the local machine to which the socket will be bound.]]
 
-[*Convenience header: ][^boost/asio.hpp]
+]
 
 
-[endsect]
+[heading Exceptions]
+
 
+[variablelist
+
+[[boost::system::system_error][Thrown on failure.]]
 
+]
 
-[section:io_service basic_serial_port::io_service]
 
+[heading Example]
+
 
-['Inherited from basic_io_object.]
 
-[indexterm2 io_service..basic_serial_port]
-(Deprecated: use `get_io_service()`.) Get the [link boost_asio.reference.io_service `io_service`] associated with the object.
+ boost::asio::ip::tcp::socket socket(io_service);
+ socket.open(boost::asio::ip::tcp::v4());
+ socket.bind(boost::asio::ip::tcp::endpoint(
+ boost::asio::ip::tcp::v4(), 12345));
 
 
- boost::asio::io_service & io_service();
 
 
-This function may be used to obtain the [link boost_asio.reference.io_service `io_service`] object that the I/O object uses to dispatch handlers for asynchronous operations.
 
 
-[heading Return Value]
-
-A reference to the [link boost_asio.reference.io_service `io_service`] object that the I/O object will use to dispatch handlers. Ownership is not transferred to the caller.
 
+[endsect]
 
 
 
-[endsect]
+[section:overload2 basic_seq_packet_socket::bind (2 of 2 overloads)]
 
 
+['Inherited from basic_socket.]
 
-[section:is_open basic_serial_port::is_open]
 
-[indexterm2 is_open..basic_serial_port]
-Determine whether the serial port is open.
+Bind the socket to the given local endpoint.
 
 
- bool is_open() const;
+ boost::system::error_code bind(
+ const endpoint_type & endpoint,
+ boost::system::error_code & ec);
 
 
+This function binds the socket to the specified endpoint on the local machine.
 
-[endsect]
 
+[heading Parameters]
+
 
-[section:lowest_layer basic_serial_port::lowest_layer]
+[variablelist
+
+[[endpoint][An endpoint on the local machine to which the socket will be bound.]]
 
-[indexterm2 lowest_layer..basic_serial_port]
-Get a reference to the lowest layer.
+[[ec][Set to indicate what error occurred, if any.]]
 
+]
 
- lowest_layer_type & ``[link boost_asio.reference.basic_serial_port.lowest_layer.overload1 lowest_layer]``();
- `` [''''&raquo;''' [link boost_asio.reference.basic_serial_port.lowest_layer.overload1 more...]]``
 
+[heading Example]
+
 
-Get a const reference to the lowest layer.
 
+ boost::asio::ip::tcp::socket socket(io_service);
+ socket.open(boost::asio::ip::tcp::v4());
+ boost::system::error_code ec;
+ socket.bind(boost::asio::ip::tcp::endpoint(
+ boost::asio::ip::tcp::v4(), 12345), ec);
+ if (ec)
+ {
+ // An error occurred.
+ }
 
- const lowest_layer_type & ``[link boost_asio.reference.basic_serial_port.lowest_layer.overload2 lowest_layer]``() const;
- `` [''''&raquo;''' [link boost_asio.reference.basic_serial_port.lowest_layer.overload2 more...]]``
 
 
-[section:overload1 basic_serial_port::lowest_layer (1 of 2 overloads)]
 
 
-Get a reference to the lowest layer.
 
 
- lowest_layer_type & lowest_layer();
+[endsect]
 
 
-This function returns a reference to the lowest layer in a stack of layers. Since a [link boost_asio.reference.basic_serial_port `basic_serial_port`] cannot contain any further layers, it simply returns a reference to itself.
+[endsect]
 
 
-[heading Return Value]
-
-A reference to the lowest layer in the stack of layers. Ownership is not transferred to the caller.
+[section:broadcast basic_seq_packet_socket::broadcast]
 
 
+['Inherited from socket_base.]
 
+[indexterm2 broadcast..basic_seq_packet_socket]
+Socket option to permit sending of broadcast messages.
 
-[endsect]
 
+ typedef implementation_defined broadcast;
 
 
-[section:overload2 basic_serial_port::lowest_layer (2 of 2 overloads)]
 
+Implements the SOL\_SOCKET/SO\_BROADCAST socket option.
 
-Get a const reference to the lowest layer.
 
+[heading Examples]
+
+Setting the option:
 
- const lowest_layer_type & lowest_layer() const;
+ boost::asio::ip::udp::socket socket(io_service);
+ ...
+ boost::asio::socket_base::broadcast option(true);
+ socket.set_option(option);
 
 
-This function returns a const reference to the lowest layer in a stack of layers. Since a [link boost_asio.reference.basic_serial_port `basic_serial_port`] cannot contain any further layers, it simply returns a reference to itself.
 
 
-[heading Return Value]
-
-A const reference to the lowest layer in the stack of layers. Ownership is not transferred to the caller.
 
+Getting the current option value:
 
+ boost::asio::ip::udp::socket socket(io_service);
+ ...
+ boost::asio::socket_base::broadcast option;
+ socket.get_option(option);
+ bool is_set = option.value();
 
 
-[endsect]
 
 
-[endsect]
 
 
-[section:lowest_layer_type basic_serial_port::lowest_layer_type]
 
-[indexterm2 lowest_layer_type..basic_serial_port]
-A [link boost_asio.reference.basic_serial_port `basic_serial_port`] is always the lowest layer.
+[heading Requirements]
 
+[*Header: ][^boost/asio/basic_seq_packet_socket.hpp]
 
- typedef basic_serial_port< SerialPortService > lowest_layer_type;
+[*Convenience header: ][^boost/asio.hpp]
 
 
-[heading Types]
-[table
- [[Name][Description]]
+[endsect]
 
- [
 
- [[link boost_asio.reference.basic_serial_port.implementation_type [*implementation_type]]]
- [The underlying implementation type of I/O object. ]
-
- ]
 
- [
+[section:bytes_readable basic_seq_packet_socket::bytes_readable]
 
- [[link boost_asio.reference.basic_serial_port.lowest_layer_type [*lowest_layer_type]]]
- [A basic_serial_port is always the lowest layer. ]
-
- ]
 
- [
+['Inherited from socket_base.]
 
- [[link boost_asio.reference.basic_serial_port.native_type [*native_type]]]
- [The native representation of a serial port. ]
-
- ]
+[indexterm2 bytes_readable..basic_seq_packet_socket]
+IO control command to get the amount of data that can be read without blocking.
 
- [
 
- [[link boost_asio.reference.basic_serial_port.service_type [*service_type]]]
- [The type of the service that will be used to provide I/O operations. ]
-
- ]
+ typedef implementation_defined bytes_readable;
 
-]
 
-[heading Member Functions]
-[table
- [[Name][Description]]
 
- [
- [[link boost_asio.reference.basic_serial_port.assign [*assign]]]
- [Assign an existing native serial port to the serial port. ]
- ]
-
- [
- [[link boost_asio.reference.basic_serial_port.async_read_some [*async_read_some]]]
- [Start an asynchronous read. ]
- ]
-
- [
- [[link boost_asio.reference.basic_serial_port.async_write_some [*async_write_some]]]
- [Start an asynchronous write. ]
- ]
-
- [
- [[link boost_asio.reference.basic_serial_port.basic_serial_port [*basic_serial_port]]]
- [Construct a basic_serial_port without opening it.
+Implements the FIONREAD IO control command.
 
- Construct and open a basic_serial_port.
 
- Construct a basic_serial_port on an existing native serial port. ]
- ]
-
- [
- [[link boost_asio.reference.basic_serial_port.cancel [*cancel]]]
- [Cancel all asynchronous operations associated with the serial port. ]
- ]
-
- [
- [[link boost_asio.reference.basic_serial_port.close [*close]]]
- [Close the serial port. ]
- ]
-
- [
- [[link boost_asio.reference.basic_serial_port.get_io_service [*get_io_service]]]
- [Get the io_service associated with the object. ]
- ]
-
- [
- [[link boost_asio.reference.basic_serial_port.get_option [*get_option]]]
- [Get an option from the serial port. ]
- ]
-
- [
- [[link boost_asio.reference.basic_serial_port.io_service [*io_service]]]
- [(Deprecated: use get_io_service().) Get the io_service associated with the object. ]
- ]
-
- [
- [[link boost_asio.reference.basic_serial_port.is_open [*is_open]]]
- [Determine whether the serial port is open. ]
- ]
+[heading Example]
   
- [
- [[link boost_asio.reference.basic_serial_port.lowest_layer [*lowest_layer]]]
- [Get a reference to the lowest layer.
 
- Get a const reference to the lowest layer. ]
- ]
-
- [
- [[link boost_asio.reference.basic_serial_port.native [*native]]]
- [Get the native serial port representation. ]
- ]
-
- [
- [[link boost_asio.reference.basic_serial_port.open [*open]]]
- [Open the serial port using the specified device name. ]
- ]
-
- [
- [[link boost_asio.reference.basic_serial_port.read_some [*read_some]]]
- [Read some data from the serial port. ]
- ]
-
- [
- [[link boost_asio.reference.basic_serial_port.send_break [*send_break]]]
- [Send a break sequence to the serial port. ]
- ]
-
- [
- [[link boost_asio.reference.basic_serial_port.set_option [*set_option]]]
- [Set an option on the serial port. ]
- ]
-
- [
- [[link boost_asio.reference.basic_serial_port.write_some [*write_some]]]
- [Write some data to the serial port. ]
- ]
-
-]
 
-[heading Protected Data Members]
-[table
- [[Name][Description]]
+ boost::asio::ip::tcp::socket socket(io_service);
+ ...
+ boost::asio::socket_base::bytes_readable command(true);
+ socket.io_control(command);
+ std::size_t bytes_readable = command.get();
 
- [
- [[link boost_asio.reference.basic_serial_port.implementation [*implementation]]]
- [The underlying implementation of the I/O object. ]
- ]
 
- [
- [[link boost_asio.reference.basic_serial_port.service [*service]]]
- [The service associated with the I/O object. ]
- ]
 
-]
 
-The [link boost_asio.reference.basic_serial_port `basic_serial_port`] class template provides functionality that is common to all serial ports.
 
 
-[heading Thread Safety]
-
-[*Distinct] [*objects:] Safe.
 
-[*Shared] [*objects:] Unsafe.
+[heading Requirements]
 
+[*Header: ][^boost/asio/basic_seq_packet_socket.hpp]
 
+[*Convenience header: ][^boost/asio.hpp]
 
 
-[heading Requirements]
+[endsect]
 
-[*Header: ][^boost/asio/basic_serial_port.hpp]
 
-[*Convenience header: ][^boost/asio.hpp]
+[section:cancel basic_seq_packet_socket::cancel]
 
+[indexterm2 cancel..basic_seq_packet_socket]
+Cancel all asynchronous operations associated with the socket.
 
-[endsect]
 
+ void ``[link boost_asio.reference.basic_seq_packet_socket.cancel.overload1 cancel]``();
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.cancel.overload1 more...]]``
 
+ boost::system::error_code ``[link boost_asio.reference.basic_seq_packet_socket.cancel.overload2 cancel]``(
+ boost::system::error_code & ec);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.cancel.overload2 more...]]``
 
-[section:native basic_serial_port::native]
 
-[indexterm2 native..basic_serial_port]
-Get the native serial port representation.
+[section:overload1 basic_seq_packet_socket::cancel (1 of 2 overloads)]
 
 
- native_type native();
+['Inherited from basic_socket.]
 
 
-This function may be used to obtain the underlying representation of the serial port. This is intended to allow access to native serial port functionality that is not otherwise provided.
+Cancel all asynchronous operations associated with the socket.
 
 
-[endsect]
+ void cancel();
 
 
+This function causes all outstanding asynchronous connect, send and receive operations to finish immediately, and the handlers for cancelled operations will be passed the `boost::asio::error::operation_aborted` error.
 
-[section:native_type basic_serial_port::native_type]
 
-[indexterm2 native_type..basic_serial_port]
-The native representation of a serial port.
+[heading Exceptions]
+
 
+[variablelist
+
+[[boost::system::system_error][Thrown on failure.]]
 
- typedef SerialPortService::native_type native_type;
+]
 
 
+[heading Remarks]
+
+Calls to `cancel()` will always fail with `boost::asio::error::operation_not_supported` when run on Windows XP, Windows Server 2003, and earlier versions of Windows, unless BOOST\_ASIO\_ENABLE\_CANCELIO is defined. However, the CancelIo function has two issues that should be considered before enabling its use:
 
-[heading Requirements]
 
-[*Header: ][^boost/asio/basic_serial_port.hpp]
+* It will only cancel asynchronous operations that were initiated in the current thread.
 
-[*Convenience header: ][^boost/asio.hpp]
 
+* It can appear to complete without error, but the request to cancel the unfinished operations may be silently ignored by the operating system. Whether it works or not seems to depend on the drivers that are installed.
 
-[endsect]
+For portable cancellation, consider using one of the following alternatives:
 
 
-[section:open basic_serial_port::open]
+* Disable asio's I/O completion port backend by defining BOOST\_ASIO\_DISABLE\_IOCP.
 
-[indexterm2 open..basic_serial_port]
-Open the serial port using the specified device name.
 
+* Use the `close()` function to simultaneously cancel the outstanding operations and close the socket.
 
- void ``[link boost_asio.reference.basic_serial_port.open.overload1 open]``(
- const std::string & device);
- `` [''''&raquo;''' [link boost_asio.reference.basic_serial_port.open.overload1 more...]]``
+When running on Windows Vista, Windows Server 2008, and later, the CancelIoEx function is always used. This function does not have the problems described above.
 
- boost::system::error_code ``[link boost_asio.reference.basic_serial_port.open.overload2 open]``(
- const std::string & device,
- boost::system::error_code & ec);
- `` [''''&raquo;''' [link boost_asio.reference.basic_serial_port.open.overload2 more...]]``
 
+[endsect]
 
-[section:overload1 basic_serial_port::open (1 of 2 overloads)]
 
 
-Open the serial port using the specified device name.
+[section:overload2 basic_seq_packet_socket::cancel (2 of 2 overloads)]
 
 
- void open(
- const std::string & device);
+['Inherited from basic_socket.]
 
 
-This function opens the serial port for the specified device name.
+Cancel all asynchronous operations associated with the socket.
 
 
-[heading Parameters]
-
+ boost::system::error_code cancel(
+ boost::system::error_code & ec);
 
-[variablelist
-
-[[device][The platform-specific device name.]]
 
-]
+This function causes all outstanding asynchronous connect, send and receive operations to finish immediately, and the handlers for cancelled operations will be passed the `boost::asio::error::operation_aborted` error.
 
 
-[heading Exceptions]
+[heading Parameters]
     
 
 [variablelist
   
-[[boost::system::system_error][Thrown on failure. ]]
+[[ec][Set to indicate what error occurred, if any.]]
 
 ]
 
 
+[heading Remarks]
+
+Calls to `cancel()` will always fail with `boost::asio::error::operation_not_supported` when run on Windows XP, Windows Server 2003, and earlier versions of Windows, unless BOOST\_ASIO\_ENABLE\_CANCELIO is defined. However, the CancelIo function has two issues that should be considered before enabling its use:
 
 
-[endsect]
-
-
-
-[section:overload2 basic_serial_port::open (2 of 2 overloads)]
-
-
-Open the serial port using the specified device name.
-
-
- boost::system::error_code open(
- const std::string & device,
- boost::system::error_code & ec);
-
+* It will only cancel asynchronous operations that were initiated in the current thread.
 
-This function opens the serial port using the given platform-specific device name.
 
+* It can appear to complete without error, but the request to cancel the unfinished operations may be silently ignored by the operating system. Whether it works or not seems to depend on the drivers that are installed.
 
-[heading Parameters]
-
+For portable cancellation, consider using one of the following alternatives:
 
-[variablelist
-
-[[device][The platform-specific device name.]]
 
-[[ec][Set the indicate what error occurred, if any. ]]
+* Disable asio's I/O completion port backend by defining BOOST\_ASIO\_DISABLE\_IOCP.
 
-]
 
+* Use the `close()` function to simultaneously cancel the outstanding operations and close the socket.
 
+When running on Windows Vista, Windows Server 2008, and later, the CancelIoEx function is always used. This function does not have the problems described above.
 
 
 [endsect]
@@ -14754,54 +16663,33 @@
 
 [endsect]
 
-[section:read_some basic_serial_port::read_some]
+[section:close basic_seq_packet_socket::close]
 
-[indexterm2 read_some..basic_serial_port]
-Read some data from the serial port.
+[indexterm2 close..basic_seq_packet_socket]
+Close the socket.
 
 
- template<
- typename ``[link boost_asio.reference.MutableBufferSequence MutableBufferSequence]``>
- std::size_t ``[link boost_asio.reference.basic_serial_port.read_some.overload1 read_some]``(
- const MutableBufferSequence & buffers);
- `` [''''&raquo;''' [link boost_asio.reference.basic_serial_port.read_some.overload1 more...]]``
+ void ``[link boost_asio.reference.basic_seq_packet_socket.close.overload1 close]``();
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.close.overload1 more...]]``
 
- template<
- typename ``[link boost_asio.reference.MutableBufferSequence MutableBufferSequence]``>
- std::size_t ``[link boost_asio.reference.basic_serial_port.read_some.overload2 read_some]``(
- const MutableBufferSequence & buffers,
+ boost::system::error_code ``[link boost_asio.reference.basic_seq_packet_socket.close.overload2 close]``(
       boost::system::error_code & ec);
- `` [''''&raquo;''' [link boost_asio.reference.basic_serial_port.read_some.overload2 more...]]``
-
-
-[section:overload1 basic_serial_port::read_some (1 of 2 overloads)]
-
-
-Read some data from the serial port.
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.close.overload2 more...]]``
 
 
- template<
- typename ``[link boost_asio.reference.MutableBufferSequence MutableBufferSequence]``>
- std::size_t read_some(
- const MutableBufferSequence & buffers);
+[section:overload1 basic_seq_packet_socket::close (1 of 2 overloads)]
 
 
-This function is used to read data from the serial port. The function call will block until one or more bytes of data has been read successfully, or until an error occurs.
+['Inherited from basic_socket.]
 
 
-[heading Parameters]
-
+Close the socket.
 
-[variablelist
-
-[[buffers][One or more buffers into which the data will be read.]]
 
-]
+ void close();
 
 
-[heading Return Value]
-
-The number of bytes read.
+This function is used to close the socket. Any asynchronous send, receive or connect operations will be cancelled immediately, and will complete with the `boost::asio::error::operation_aborted` error.
 
 
 [heading Exceptions]
@@ -14809,46 +16697,36 @@
 
 [variablelist
   
-[[boost::system::system_error][Thrown on failure. An error code of `boost::asio::error::eof` indicates that the connection was closed by the peer.]]
+[[boost::system::system_error][Thrown on failure.]]
 
 ]
 
 
 [heading Remarks]
       
-The read\_some operation may not read all of the requested number of bytes. Consider using the [link boost_asio.reference.read `read`] function if you need to ensure that the requested amount of data is read before the blocking operation completes.
-
-
-[heading Example]
-
-To read into a single data buffer use the [link boost_asio.reference.buffer `buffer`] function as follows:
-
- serial_port.read_some(boost::asio::buffer(data, size));
+For portable behaviour with respect to graceful closure of a connected socket, call `shutdown()` before closing the socket.
 
 
-See the [link boost_asio.reference.buffer `buffer`] documentation for information on reading into multiple buffers in one go, and how to use it with arrays, boost::array or std::vector.
 
 
+[endsect]
 
 
-[endsect]
 
+[section:overload2 basic_seq_packet_socket::close (2 of 2 overloads)]
 
 
-[section:overload2 basic_serial_port::read_some (2 of 2 overloads)]
+['Inherited from basic_socket.]
 
 
-Read some data from the serial port.
+Close the socket.
 
 
- template<
- typename ``[link boost_asio.reference.MutableBufferSequence MutableBufferSequence]``>
- std::size_t read_some(
- const MutableBufferSequence & buffers,
+ boost::system::error_code close(
       boost::system::error_code & ec);
 
 
-This function is used to read data from the serial port. The function call will block until one or more bytes of data has been read successfully, or until an error occurs.
+This function is used to close the socket. Any asynchronous send, receive or connect operations will be cancelled immediately, and will complete with the `boost::asio::error::operation_aborted` error.
 
 
 [heading Parameters]
@@ -14856,21 +16734,31 @@
 
 [variablelist
   
-[[buffers][One or more buffers into which the data will be read.]]
-
 [[ec][Set to indicate what error occurred, if any.]]
 
 ]
 
 
-[heading Return Value]
-
-The number of bytes read. Returns 0 if an error occurred.
+[heading Example]
+
+
+
+ boost::asio::ip::tcp::socket socket(io_service);
+ ...
+ boost::system::error_code ec;
+ socket.close(ec);
+ if (ec)
+ {
+ // An error occurred.
+ }
+
+
+
 
 
 [heading Remarks]
       
-The read\_some operation may not read all of the requested number of bytes. Consider using the [link boost_asio.reference.read `read`] function if you need to ensure that the requested amount of data is read before the blocking operation completes.
+For portable behaviour with respect to graceful closure of a connected socket, call `shutdown()` before closing the socket.
 
 
 
@@ -14880,59 +16768,96 @@
 
 [endsect]
 
-[section:send_break basic_serial_port::send_break]
+[section:connect basic_seq_packet_socket::connect]
 
-[indexterm2 send_break..basic_serial_port]
-Send a break sequence to the serial port.
+[indexterm2 connect..basic_seq_packet_socket]
+Connect the socket to the specified endpoint.
 
 
- void ``[link boost_asio.reference.basic_serial_port.send_break.overload1 send_break]``();
- `` [''''&raquo;''' [link boost_asio.reference.basic_serial_port.send_break.overload1 more...]]``
+ void ``[link boost_asio.reference.basic_seq_packet_socket.connect.overload1 connect]``(
+ const endpoint_type & peer_endpoint);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.connect.overload1 more...]]``
 
- boost::system::error_code ``[link boost_asio.reference.basic_serial_port.send_break.overload2 send_break]``(
+ boost::system::error_code ``[link boost_asio.reference.basic_seq_packet_socket.connect.overload2 connect]``(
+ const endpoint_type & peer_endpoint,
       boost::system::error_code & ec);
- `` [''''&raquo;''' [link boost_asio.reference.basic_serial_port.send_break.overload2 more...]]``
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.connect.overload2 more...]]``
 
 
-[section:overload1 basic_serial_port::send_break (1 of 2 overloads)]
+[section:overload1 basic_seq_packet_socket::connect (1 of 2 overloads)]
 
 
-Send a break sequence to the serial port.
+['Inherited from basic_socket.]
 
 
- void send_break();
+Connect the socket to the specified endpoint.
 
 
-This function causes a break sequence of platform-specific duration to be sent out the serial port.
+ void connect(
+ const endpoint_type & peer_endpoint);
 
 
-[heading Exceptions]
+This function is used to connect a socket to the specified remote endpoint. The function call will block until the connection is successfully made or an error occurs.
+
+The socket is automatically opened if it is not already open. If the connect fails, and the socket was automatically opened, the socket is not returned to the closed state.
+
+
+[heading Parameters]
     
 
 [variablelist
   
-[[boost::system::system_error][Thrown on failure. ]]
+[[peer_endpoint][The remote endpoint to which the socket will be connected.]]
 
 ]
 
 
+[heading Exceptions]
+
 
+[variablelist
+
+[[boost::system::system_error][Thrown on failure.]]
 
-[endsect]
-
+]
 
 
-[section:overload2 basic_serial_port::send_break (2 of 2 overloads)]
+[heading Example]
+
 
 
-Send a break sequence to the serial port.
+ boost::asio::ip::tcp::socket socket(io_service);
+ boost::asio::ip::tcp::endpoint endpoint(
+ boost::asio::ip::address::from_string("1.2.3.4"), 12345);
+ socket.connect(endpoint);
 
 
- boost::system::error_code send_break(
+
+
+
+
+
+[endsect]
+
+
+
+[section:overload2 basic_seq_packet_socket::connect (2 of 2 overloads)]
+
+
+['Inherited from basic_socket.]
+
+
+Connect the socket to the specified endpoint.
+
+
+ boost::system::error_code connect(
+ const endpoint_type & peer_endpoint,
       boost::system::error_code & ec);
 
 
-This function causes a break sequence of platform-specific duration to be sent out the serial port.
+This function is used to connect a socket to the specified remote endpoint. The function call will block until the connection is successfully made or an error occurs.
+
+The socket is automatically opened if it is not already open. If the connect fails, and the socket was automatically opened, the socket is not returned to the closed state.
 
 
 [heading Parameters]
@@ -14940,11 +16865,31 @@
 
 [variablelist
   
-[[ec][Set to indicate what error occurred, if any. ]]
+[[peer_endpoint][The remote endpoint to which the socket will be connected.]]
+
+[[ec][Set to indicate what error occurred, if any.]]
 
 ]
 
 
+[heading Example]
+
+
+
+ boost::asio::ip::tcp::socket socket(io_service);
+ boost::asio::ip::tcp::endpoint endpoint(
+ boost::asio::ip::address::from_string("1.2.3.4"), 12345);
+ boost::system::error_code ec;
+ socket.connect(endpoint, ec);
+ if (ec)
+ {
+ // An error occurred.
+ }
+
+
+
+
+
 
 
 [endsect]
@@ -14953,39 +16898,52 @@
 [endsect]
 
 
-[section:service basic_serial_port::service]
+[section:debug basic_seq_packet_socket::debug]
 
 
-['Inherited from basic_io_object.]
+['Inherited from socket_base.]
 
-[indexterm2 service..basic_serial_port]
-The service associated with the I/O object.
+[indexterm2 debug..basic_seq_packet_socket]
+Socket option to enable socket-level debugging.
 
 
- service_type & service;
+ typedef implementation_defined debug;
 
 
 
-[endsect]
+Implements the SOL\_SOCKET/SO\_DEBUG socket option.
 
 
+[heading Examples]
+
+Setting the option:
 
-[section:service_type basic_serial_port::service_type]
+ boost::asio::ip::tcp::socket socket(io_service);
+ ...
+ boost::asio::socket_base::debug option(true);
+ socket.set_option(option);
 
 
-['Inherited from basic_io_object.]
 
-[indexterm2 service_type..basic_serial_port]
-The type of the service that will be used to provide I/O operations.
 
 
- typedef SerialPortService service_type;
+Getting the current option value:
+
+ boost::asio::ip::tcp::socket socket(io_service);
+ ...
+ boost::asio::socket_base::debug option;
+ socket.get_option(option);
+ bool is_set = option.value();
+
+
+
+
 
 
 
 [heading Requirements]
 
-[*Header: ][^boost/asio/basic_serial_port.hpp]
+[*Header: ][^boost/asio/basic_seq_packet_socket.hpp]
 
 [*Convenience header: ][^boost/asio.hpp]
 
@@ -14993,137 +16951,193 @@
 [endsect]
 
 
-[section:set_option basic_serial_port::set_option]
 
-[indexterm2 set_option..basic_serial_port]
-Set an option on the serial port.
+[section:do_not_route basic_seq_packet_socket::do_not_route]
 
 
- template<
- typename ``[link boost_asio.reference.SettableSerialPortOption SettableSerialPortOption]``>
- void ``[link boost_asio.reference.basic_serial_port.set_option.overload1 set_option]``(
- const SettableSerialPortOption & option);
- `` [''''&raquo;''' [link boost_asio.reference.basic_serial_port.set_option.overload1 more...]]``
+['Inherited from socket_base.]
 
- template<
- typename ``[link boost_asio.reference.SettableSerialPortOption SettableSerialPortOption]``>
- boost::system::error_code ``[link boost_asio.reference.basic_serial_port.set_option.overload2 set_option]``(
- const SettableSerialPortOption & option,
- boost::system::error_code & ec);
- `` [''''&raquo;''' [link boost_asio.reference.basic_serial_port.set_option.overload2 more...]]``
+[indexterm2 do_not_route..basic_seq_packet_socket]
+Socket option to prevent routing, use local interfaces only.
 
 
-[section:overload1 basic_serial_port::set_option (1 of 2 overloads)]
+ typedef implementation_defined do_not_route;
 
 
-Set an option on the serial port.
 
+Implements the SOL\_SOCKET/SO\_DONTROUTE socket option.
 
- template<
- typename ``[link boost_asio.reference.SettableSerialPortOption SettableSerialPortOption]``>
- void set_option(
- const SettableSerialPortOption & option);
 
+[heading Examples]
+
+Setting the option:
 
-This function is used to set an option on the serial port.
+ boost::asio::ip::udp::socket socket(io_service);
+ ...
+ boost::asio::socket_base::do_not_route option(true);
+ socket.set_option(option);
 
 
-[heading Parameters]
-
 
-[variablelist
-
-[[option][The option value to be set on the serial port.]]
 
-]
+
+Getting the current option value:
+
+ boost::asio::ip::udp::socket socket(io_service);
+ ...
+ boost::asio::socket_base::do_not_route option;
+ socket.get_option(option);
+ bool is_set = option.value();
 
 
-[heading Exceptions]
-
 
-[variablelist
-
-[[boost::system::system_error][Thrown on failure.]]
 
-]
 
 
 
+[heading Requirements]
+
+[*Header: ][^boost/asio/basic_seq_packet_socket.hpp]
+
+[*Convenience header: ][^boost/asio.hpp]
 
 
 [endsect]
 
 
 
-[section:overload2 basic_serial_port::set_option (2 of 2 overloads)]
+[section:enable_connection_aborted basic_seq_packet_socket::enable_connection_aborted]
 
 
-Set an option on the serial port.
+['Inherited from socket_base.]
 
+[indexterm2 enable_connection_aborted..basic_seq_packet_socket]
+Socket option to report aborted connections on accept.
 
- template<
- typename ``[link boost_asio.reference.SettableSerialPortOption SettableSerialPortOption]``>
- boost::system::error_code set_option(
- const SettableSerialPortOption & option,
- boost::system::error_code & ec);
 
+ typedef implementation_defined enable_connection_aborted;
 
-This function is used to set an option on the serial port.
 
 
-[heading Parameters]
-
+Implements a custom socket option that determines whether or not an accept operation is permitted to fail with `boost::asio::error::connection_aborted`. By default the option is false.
 
-[variablelist
+
+[heading Examples]
   
-[[option][The option value to be set on the serial port.]]
+Setting the option:
 
-[[ec][Set to indicate what error occurred, if any.]]
+ boost::asio::ip::tcp::acceptor acceptor(io_service);
+ ...
+ boost::asio::socket_base::enable_connection_aborted option(true);
+ acceptor.set_option(option);
 
-]
 
 
 
 
+Getting the current option value:
+
+ boost::asio::ip::tcp::acceptor acceptor(io_service);
+ ...
+ boost::asio::socket_base::enable_connection_aborted option;
+ acceptor.get_option(option);
+ bool is_set = option.value();
+
+
+
+
+
+
+
+[heading Requirements]
+
+[*Header: ][^boost/asio/basic_seq_packet_socket.hpp]
+
+[*Convenience header: ][^boost/asio.hpp]
+
+
+[endsect]
+
+
+
+[section:endpoint_type basic_seq_packet_socket::endpoint_type]
+
+[indexterm2 endpoint_type..basic_seq_packet_socket]
+The endpoint type.
+
+
+ typedef Protocol::endpoint endpoint_type;
+
+
+
+[heading Requirements]
+
+[*Header: ][^boost/asio/basic_seq_packet_socket.hpp]
+
+[*Convenience header: ][^boost/asio.hpp]
+
 
 [endsect]
 
 
+
+[section:get_io_service basic_seq_packet_socket::get_io_service]
+
+
+['Inherited from basic_io_object.]
+
+[indexterm2 get_io_service..basic_seq_packet_socket]
+Get the [link boost_asio.reference.io_service `io_service`] associated with the object.
+
+
+ boost::asio::io_service & get_io_service();
+
+
+This function may be used to obtain the [link boost_asio.reference.io_service `io_service`] object that the I/O object uses to dispatch handlers for asynchronous operations.
+
+
+[heading Return Value]
+
+A reference to the [link boost_asio.reference.io_service `io_service`] object that the I/O object will use to dispatch handlers. Ownership is not transferred to the caller.
+
+
+
+
 [endsect]
 
-[section:write_some basic_serial_port::write_some]
 
-[indexterm2 write_some..basic_serial_port]
-Write some data to the serial port.
+[section:get_option basic_seq_packet_socket::get_option]
 
+[indexterm2 get_option..basic_seq_packet_socket]
+Get an option from the socket.
 
- template<
- typename ``[link boost_asio.reference.ConstBufferSequence ConstBufferSequence]``>
- std::size_t ``[link boost_asio.reference.basic_serial_port.write_some.overload1 write_some]``(
- const ConstBufferSequence & buffers);
- `` [''''&raquo;''' [link boost_asio.reference.basic_serial_port.write_some.overload1 more...]]``
 
- template<
- typename ``[link boost_asio.reference.ConstBufferSequence ConstBufferSequence]``>
- std::size_t ``[link boost_asio.reference.basic_serial_port.write_some.overload2 write_some]``(
- const ConstBufferSequence & buffers,
- boost::system::error_code & ec);
- `` [''''&raquo;''' [link boost_asio.reference.basic_serial_port.write_some.overload2 more...]]``
+ void ``[link boost_asio.reference.basic_seq_packet_socket.get_option.overload1 get_option]``(
+ GettableSocketOption & option) const;
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.get_option.overload1 more...]]``
+
+ boost::system::error_code ``[link boost_asio.reference.basic_seq_packet_socket.get_option.overload2 get_option]``(
+ GettableSocketOption & option,
+ boost::system::error_code & ec) const;
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.get_option.overload2 more...]]``
 
 
-[section:overload1 basic_serial_port::write_some (1 of 2 overloads)]
+[section:overload1 basic_seq_packet_socket::get_option (1 of 2 overloads)]
 
 
-Write some data to the serial port.
+['Inherited from basic_socket.]
+
+
+Get an option from the socket.
 
 
   template<
- typename ``[link boost_asio.reference.ConstBufferSequence ConstBufferSequence]``>
- std::size_t write_some(
- const ConstBufferSequence & buffers);
+ typename ``[link boost_asio.reference.GettableSocketOption GettableSocketOption]``>
+ void get_option(
+ GettableSocketOption & option) const;
 
 
-This function is used to write data to the serial port. The function call will block until one or more bytes of the data has been written successfully, or until an error occurs.
+This function is used to get the current value of an option on the socket.
 
 
 [heading Parameters]
@@ -15131,39 +17145,34 @@
 
 [variablelist
   
-[[buffers][One or more data buffers to be written to the serial port.]]
+[[option][The option value to be obtained from the socket.]]
 
 ]
 
 
-[heading Return Value]
-
-The number of bytes written.
-
-
 [heading Exceptions]
     
 
 [variablelist
   
-[[boost::system::system_error][Thrown on failure. An error code of `boost::asio::error::eof` indicates that the connection was closed by the peer.]]
+[[boost::system::system_error][Thrown on failure.]]
 
 ]
 
 
-[heading Remarks]
-
-The write\_some operation may not transmit all of the data to the peer. Consider using the [link boost_asio.reference.write `write`] function if you need to ensure that all data is written before the blocking operation completes.
-
 
 [heading Example]
   
-To write a single data buffer use the [link boost_asio.reference.buffer `buffer`] function as follows:
+Getting the value of the SOL\_SOCKET/SO\_KEEPALIVE option:
+
+ boost::asio::ip::tcp::socket socket(io_service);
+ ...
+ boost::asio::ip::tcp::socket::keep_alive option;
+ socket.get_option(option);
+ bool is_set = option.get();
 
- serial_port.write_some(boost::asio::buffer(data, size));
 
 
-See the [link boost_asio.reference.buffer `buffer`] documentation for information on writing multiple buffers in one go, and how to use it with arrays, boost::array or std::vector.
 
 
 
@@ -15172,20 +17181,23 @@
 
 
 
-[section:overload2 basic_serial_port::write_some (2 of 2 overloads)]
+[section:overload2 basic_seq_packet_socket::get_option (2 of 2 overloads)]
 
 
-Write some data to the serial port.
+['Inherited from basic_socket.]
+
+
+Get an option from the socket.
 
 
   template<
- typename ``[link boost_asio.reference.ConstBufferSequence ConstBufferSequence]``>
- std::size_t write_some(
- const ConstBufferSequence & buffers,
- boost::system::error_code & ec);
+ typename ``[link boost_asio.reference.GettableSocketOption GettableSocketOption]``>
+ boost::system::error_code get_option(
+ GettableSocketOption & option,
+ boost::system::error_code & ec) const;
 
 
-This function is used to write data to the serial port. The function call will block until one or more bytes of the data has been written successfully, or until an error occurs.
+This function is used to get the current value of an option on the socket.
 
 
 [heading Parameters]
@@ -15193,26 +17205,33 @@
 
 [variablelist
   
-[[buffers][One or more data buffers to be written to the serial port.]]
+[[option][The option value to be obtained from the socket.]]
 
 [[ec][Set to indicate what error occurred, if any.]]
 
 ]
 
 
-[heading Return Value]
-
-The number of bytes written. Returns 0 if an error occurred.
 
+[heading Example]
+
+Getting the value of the SOL\_SOCKET/SO\_KEEPALIVE option:
+
+ boost::asio::ip::tcp::socket socket(io_service);
+ ...
+ boost::asio::ip::tcp::socket::keep_alive option;
+ boost::system::error_code ec;
+ socket.get_option(option, ec);
+ if (ec)
+ {
+ // An error occurred.
+ }
+ bool is_set = option.get();
 
-[heading Remarks]
-
-The write\_some operation may not transmit all of the data to the peer. Consider using the [link boost_asio.reference.write `write`] function if you need to ensure that all data is written before the blocking operation completes.
 
 
 
 
-[endsect]
 
 
 [endsect]
@@ -15220,590 +17239,338 @@
 
 [endsect]
 
-[section:basic_socket basic_socket]
-
 
-Provides socket functionality.
+[section:implementation basic_seq_packet_socket::implementation]
 
 
- template<
- typename ``[link boost_asio.reference.Protocol Protocol]``,
- typename ``[link boost_asio.reference.SocketService SocketService]``>
- class basic_socket :
- public basic_io_object< SocketService >,
- public socket_base
+['Inherited from basic_io_object.]
 
+[indexterm2 implementation..basic_seq_packet_socket]
+The underlying implementation of the I/O object.
 
-[heading Types]
-[table
- [[Name][Description]]
 
- [
+ implementation_type implementation;
 
- [[link boost_asio.reference.basic_socket.broadcast [*broadcast]]]
- [Socket option to permit sending of broadcast messages. ]
-
- ]
 
- [
 
- [[link boost_asio.reference.basic_socket.bytes_readable [*bytes_readable]]]
- [IO control command to get the amount of data that can be read without blocking. ]
-
- ]
+[endsect]
 
- [
 
- [[link boost_asio.reference.basic_socket.debug [*debug]]]
- [Socket option to enable socket-level debugging. ]
-
- ]
 
- [
+[section:implementation_type basic_seq_packet_socket::implementation_type]
 
- [[link boost_asio.reference.basic_socket.do_not_route [*do_not_route]]]
- [Socket option to prevent routing, use local interfaces only. ]
-
- ]
 
- [
+['Inherited from basic_io_object.]
 
- [[link boost_asio.reference.basic_socket.enable_connection_aborted [*enable_connection_aborted]]]
- [Socket option to report aborted connections on accept. ]
-
- ]
+[indexterm2 implementation_type..basic_seq_packet_socket]
+The underlying implementation type of I/O object.
 
- [
 
- [[link boost_asio.reference.basic_socket.endpoint_type [*endpoint_type]]]
- [The endpoint type. ]
-
- ]
+ typedef service_type::implementation_type implementation_type;
 
- [
 
- [[link boost_asio.reference.basic_socket.implementation_type [*implementation_type]]]
- [The underlying implementation type of I/O object. ]
-
- ]
 
- [
+[heading Requirements]
 
- [[link boost_asio.reference.basic_socket.keep_alive [*keep_alive]]]
- [Socket option to send keep-alives. ]
-
- ]
+[*Header: ][^boost/asio/basic_seq_packet_socket.hpp]
 
- [
+[*Convenience header: ][^boost/asio.hpp]
 
- [[link boost_asio.reference.basic_socket.linger [*linger]]]
- [Socket option to specify whether the socket lingers on close if unsent data is present. ]
-
- ]
 
- [
+[endsect]
 
- [[link boost_asio.reference.basic_socket.lowest_layer_type [*lowest_layer_type]]]
- [A basic_socket is always the lowest layer. ]
-
- ]
 
- [
+[section:io_control basic_seq_packet_socket::io_control]
 
- [[link boost_asio.reference.basic_socket.message_flags [*message_flags]]]
- [Bitmask type for flags that can be passed to send and receive operations. ]
-
- ]
+[indexterm2 io_control..basic_seq_packet_socket]
+Perform an IO control command on the socket.
 
- [
 
- [[link boost_asio.reference.basic_socket.native_type [*native_type]]]
- [The native representation of a socket. ]
-
- ]
+ void ``[link boost_asio.reference.basic_seq_packet_socket.io_control.overload1 io_control]``(
+ IoControlCommand & command);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.io_control.overload1 more...]]``
 
- [
+ boost::system::error_code ``[link boost_asio.reference.basic_seq_packet_socket.io_control.overload2 io_control]``(
+ IoControlCommand & command,
+ boost::system::error_code & ec);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.io_control.overload2 more...]]``
 
- [[link boost_asio.reference.basic_socket.non_blocking_io [*non_blocking_io]]]
- [IO control command to set the blocking mode of the socket. ]
-
- ]
 
- [
+[section:overload1 basic_seq_packet_socket::io_control (1 of 2 overloads)]
 
- [[link boost_asio.reference.basic_socket.protocol_type [*protocol_type]]]
- [The protocol type. ]
-
- ]
 
- [
+['Inherited from basic_socket.]
 
- [[link boost_asio.reference.basic_socket.receive_buffer_size [*receive_buffer_size]]]
- [Socket option for the receive buffer size of a socket. ]
-
- ]
 
- [
+Perform an IO control command on the socket.
 
- [[link boost_asio.reference.basic_socket.receive_low_watermark [*receive_low_watermark]]]
- [Socket option for the receive low watermark. ]
-
- ]
 
- [
+ template<
+ typename ``[link boost_asio.reference.IoControlCommand IoControlCommand]``>
+ void io_control(
+ IoControlCommand & command);
 
- [[link boost_asio.reference.basic_socket.reuse_address [*reuse_address]]]
- [Socket option to allow the socket to be bound to an address that is already in use. ]
-
- ]
 
- [
+This function is used to execute an IO control command on the socket.
 
- [[link boost_asio.reference.basic_socket.send_buffer_size [*send_buffer_size]]]
- [Socket option for the send buffer size of a socket. ]
-
- ]
 
- [
+[heading Parameters]
+
 
- [[link boost_asio.reference.basic_socket.send_low_watermark [*send_low_watermark]]]
- [Socket option for the send low watermark. ]
+[variablelist
   
- ]
+[[command][The IO control command to be performed on the socket.]]
 
- [
+]
 
- [[link boost_asio.reference.basic_socket.service_type [*service_type]]]
- [The type of the service that will be used to provide I/O operations. ]
-
- ]
 
- [
+[heading Exceptions]
+
 
- [[link boost_asio.reference.basic_socket.shutdown_type [*shutdown_type]]]
- [Different ways a socket may be shutdown. ]
+[variablelist
   
- ]
+[[boost::system::system_error][Thrown on failure.]]
 
 ]
 
-[heading Member Functions]
-[table
- [[Name][Description]]
 
- [
- [[link boost_asio.reference.basic_socket.assign [*assign]]]
- [Assign an existing native socket to the socket. ]
- ]
-
- [
- [[link boost_asio.reference.basic_socket.async_connect [*async_connect]]]
- [Start an asynchronous connect. ]
- ]
-
- [
- [[link boost_asio.reference.basic_socket.at_mark [*at_mark]]]
- [Determine whether the socket is at the out-of-band data mark. ]
- ]
-
- [
- [[link boost_asio.reference.basic_socket.available [*available]]]
- [Determine the number of bytes available for reading. ]
- ]
+
+[heading Example]
   
- [
- [[link boost_asio.reference.basic_socket.basic_socket [*basic_socket]]]
- [Construct a basic_socket without opening it.
+Getting the number of bytes ready to read:
 
- Construct and open a basic_socket.
+ boost::asio::ip::tcp::socket socket(io_service);
+ ...
+ boost::asio::ip::tcp::socket::bytes_readable command;
+ socket.io_control(command);
+ std::size_t bytes_readable = command.get();
 
- Construct a basic_socket, opening it and binding it to the given local endpoint.
 
- Construct a basic_socket on an existing native socket. ]
- ]
-
- [
- [[link boost_asio.reference.basic_socket.bind [*bind]]]
- [Bind the socket to the given local endpoint. ]
- ]
-
- [
- [[link boost_asio.reference.basic_socket.cancel [*cancel]]]
- [Cancel all asynchronous operations associated with the socket. ]
- ]
-
- [
- [[link boost_asio.reference.basic_socket.close [*close]]]
- [Close the socket. ]
- ]
-
- [
- [[link boost_asio.reference.basic_socket.connect [*connect]]]
- [Connect the socket to the specified endpoint. ]
- ]
-
- [
- [[link boost_asio.reference.basic_socket.get_io_service [*get_io_service]]]
- [Get the io_service associated with the object. ]
- ]
-
- [
- [[link boost_asio.reference.basic_socket.get_option [*get_option]]]
- [Get an option from the socket. ]
- ]
-
- [
- [[link boost_asio.reference.basic_socket.io_control [*io_control]]]
- [Perform an IO control command on the socket. ]
- ]
-
- [
- [[link boost_asio.reference.basic_socket.io_service [*io_service]]]
- [(Deprecated: use get_io_service().) Get the io_service associated with the object. ]
- ]
-
- [
- [[link boost_asio.reference.basic_socket.is_open [*is_open]]]
- [Determine whether the socket is open. ]
- ]
-
- [
- [[link boost_asio.reference.basic_socket.local_endpoint [*local_endpoint]]]
- [Get the local endpoint of the socket. ]
- ]
-
- [
- [[link boost_asio.reference.basic_socket.lowest_layer [*lowest_layer]]]
- [Get a reference to the lowest layer.
-
- Get a const reference to the lowest layer. ]
- ]
-
- [
- [[link boost_asio.reference.basic_socket.native [*native]]]
- [Get the native socket representation. ]
- ]
-
- [
- [[link boost_asio.reference.basic_socket.open [*open]]]
- [Open the socket using the specified protocol. ]
- ]
-
- [
- [[link boost_asio.reference.basic_socket.remote_endpoint [*remote_endpoint]]]
- [Get the remote endpoint of the socket. ]
- ]
-
- [
- [[link boost_asio.reference.basic_socket.set_option [*set_option]]]
- [Set an option on the socket. ]
- ]
-
- [
- [[link boost_asio.reference.basic_socket.shutdown [*shutdown]]]
- [Disable sends or receives on the socket. ]
- ]
-
-]
-
-[heading Protected Member Functions]
-[table
- [[Name][Description]]
 
- [
- [[link boost_asio.reference.basic_socket._basic_socket [*~basic_socket]]]
- [Protected destructor to prevent deletion through this type. ]
- ]
-
-]
 
-[heading Data Members]
-[table
- [[Name][Description]]
 
- [
- [[link boost_asio.reference.basic_socket.max_connections [*max_connections]]]
- [The maximum length of the queue of pending incoming connections. ]
- ]
 
- [
- [[link boost_asio.reference.basic_socket.message_do_not_route [*message_do_not_route]]]
- [Specify that the data should not be subject to routing. ]
- ]
 
- [
- [[link boost_asio.reference.basic_socket.message_out_of_band [*message_out_of_band]]]
- [Process out-of-band data. ]
- ]
+[endsect]
 
- [
- [[link boost_asio.reference.basic_socket.message_peek [*message_peek]]]
- [Peek at incoming data without removing it from the input queue. ]
- ]
 
-]
 
-[heading Protected Data Members]
-[table
- [[Name][Description]]
+[section:overload2 basic_seq_packet_socket::io_control (2 of 2 overloads)]
 
- [
- [[link boost_asio.reference.basic_socket.implementation [*implementation]]]
- [The underlying implementation of the I/O object. ]
- ]
 
- [
- [[link boost_asio.reference.basic_socket.service [*service]]]
- [The service associated with the I/O object. ]
- ]
+['Inherited from basic_socket.]
 
-]
 
-The [link boost_asio.reference.basic_socket `basic_socket`] class template provides functionality that is common to both stream-oriented and datagram-oriented sockets.
+Perform an IO control command on the socket.
 
 
-[heading Thread Safety]
-
-[*Distinct] [*objects:] Safe.
+ template<
+ typename ``[link boost_asio.reference.IoControlCommand IoControlCommand]``>
+ boost::system::error_code io_control(
+ IoControlCommand & command,
+ boost::system::error_code & ec);
 
-[*Shared] [*objects:] Unsafe.
 
+This function is used to execute an IO control command on the socket.
 
 
-[heading Requirements]
+[heading Parameters]
+
 
-[*Header: ][^boost/asio/basic_socket.hpp]
+[variablelist
+
+[[command][The IO control command to be performed on the socket.]]
 
-[*Convenience header: ][^boost/asio.hpp]
+[[ec][Set to indicate what error occurred, if any.]]
 
-[section:assign basic_socket::assign]
+]
 
-[indexterm2 assign..basic_socket]
-Assign an existing native socket to the socket.
 
 
- void ``[link boost_asio.reference.basic_socket.assign.overload1 assign]``(
- const protocol_type & protocol,
- const native_type & native_socket);
- `` [''''&raquo;''' [link boost_asio.reference.basic_socket.assign.overload1 more...]]``
+[heading Example]
+
+Getting the number of bytes ready to read:
 
- boost::system::error_code ``[link boost_asio.reference.basic_socket.assign.overload2 assign]``(
- const protocol_type & protocol,
- const native_type & native_socket,
- boost::system::error_code & ec);
- `` [''''&raquo;''' [link boost_asio.reference.basic_socket.assign.overload2 more...]]``
+ boost::asio::ip::tcp::socket socket(io_service);
+ ...
+ boost::asio::ip::tcp::socket::bytes_readable command;
+ boost::system::error_code ec;
+ socket.io_control(command, ec);
+ if (ec)
+ {
+ // An error occurred.
+ }
+ std::size_t bytes_readable = command.get();
 
 
-[section:overload1 basic_socket::assign (1 of 2 overloads)]
 
 
-Assign an existing native socket to the socket.
 
 
- void assign(
- const protocol_type & protocol,
- const native_type & native_socket);
 
+[endsect]
 
 
 [endsect]
 
 
+[section:is_open basic_seq_packet_socket::is_open]
 
-[section:overload2 basic_socket::assign (2 of 2 overloads)]
 
+['Inherited from basic_socket.]
 
-Assign an existing native socket to the socket.
+[indexterm2 is_open..basic_seq_packet_socket]
+Determine whether the socket is open.
 
 
- boost::system::error_code assign(
- const protocol_type & protocol,
- const native_type & native_socket,
- boost::system::error_code & ec);
+ bool is_open() const;
 
 
 
 [endsect]
 
 
-[endsect]
 
+[section:keep_alive basic_seq_packet_socket::keep_alive]
 
-[section:async_connect basic_socket::async_connect]
 
-[indexterm2 async_connect..basic_socket]
-Start an asynchronous connect.
+['Inherited from socket_base.]
 
+[indexterm2 keep_alive..basic_seq_packet_socket]
+Socket option to send keep-alives.
 
- template<
- typename ``[link boost_asio.reference.ConnectHandler ConnectHandler]``>
- void async_connect(
- const endpoint_type & peer_endpoint,
- ConnectHandler handler);
 
+ typedef implementation_defined keep_alive;
 
-This function is used to asynchronously connect a socket to the specified remote endpoint. The function call always returns immediately.
 
-The socket is automatically opened if it is not already open. If the connect fails, and the socket was automatically opened, the socket is not returned to the closed state.
 
+Implements the SOL\_SOCKET/SO\_KEEPALIVE socket option.
 
-[heading Parameters]
-
 
-[variablelist
+[heading Examples]
   
-[[peer_endpoint][The remote endpoint to which the socket will be connected. Copies will be made of the endpoint object as required.]]
+Setting the option:
 
-[[handler][The handler to be called when the connection operation completes. Copies will be made of the handler as required. The function signature of the handler must be:
-``
- void handler(
- const boost::system::error_code& error // Result of operation
- );
-``
-Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using `boost::asio::io_service::post()`.]]
+ boost::asio::ip::tcp::socket socket(io_service);
+ ...
+ boost::asio::socket_base::keep_alive option(true);
+ socket.set_option(option);
 
-]
 
 
-[heading Example]
-
 
 
- void connect_handler(const boost::system::error_code& error)
- {
- if (!error)
- {
- // Connect succeeded.
- }
- }
+Getting the current option value:
 
+ boost::asio::ip::tcp::socket socket(io_service);
    ...
-
- boost::asio::ip::tcp::socket socket(io_service);
- boost::asio::ip::tcp::endpoint endpoint(
- boost::asio::ip::address::from_string("1.2.3.4"), 12345);
- socket.async_connect(endpoint, connect_handler);
-
-
+ boost::asio::socket_base::keep_alive option;
+ socket.get_option(option);
+ bool is_set = option.value();
 
 
 
 
 
-[endsect]
 
 
-[section:at_mark basic_socket::at_mark]
+[heading Requirements]
 
-[indexterm2 at_mark..basic_socket]
-Determine whether the socket is at the out-of-band data mark.
+[*Header: ][^boost/asio/basic_seq_packet_socket.hpp]
 
+[*Convenience header: ][^boost/asio.hpp]
 
- bool ``[link boost_asio.reference.basic_socket.at_mark.overload1 at_mark]``() const;
- `` [''''&raquo;''' [link boost_asio.reference.basic_socket.at_mark.overload1 more...]]``
 
- bool ``[link boost_asio.reference.basic_socket.at_mark.overload2 at_mark]``(
- boost::system::error_code & ec) const;
- `` [''''&raquo;''' [link boost_asio.reference.basic_socket.at_mark.overload2 more...]]``
+[endsect]
 
 
-[section:overload1 basic_socket::at_mark (1 of 2 overloads)]
 
+[section:linger basic_seq_packet_socket::linger]
 
-Determine whether the socket is at the out-of-band data mark.
 
+['Inherited from socket_base.]
 
- bool at_mark() const;
+[indexterm2 linger..basic_seq_packet_socket]
+Socket option to specify whether the socket lingers on close if unsent data is present.
 
 
-This function is used to check whether the socket input is currently positioned at the out-of-band data mark.
+ typedef implementation_defined linger;
 
 
-[heading Return Value]
-
-A bool indicating whether the socket is at the out-of-band data mark.
 
+Implements the SOL\_SOCKET/SO\_LINGER socket option.
 
-[heading Exceptions]
-
 
-[variablelist
+[heading Examples]
   
-[[boost::system::system_error][Thrown on failure. ]]
-
-]
-
-
-
-
-[endsect]
-
+Setting the option:
 
+ boost::asio::ip::tcp::socket socket(io_service);
+ ...
+ boost::asio::socket_base::linger option(true, 30);
+ socket.set_option(option);
 
-[section:overload2 basic_socket::at_mark (2 of 2 overloads)]
 
 
-Determine whether the socket is at the out-of-band data mark.
 
 
- bool at_mark(
- boost::system::error_code & ec) const;
+Getting the current option value:
 
+ boost::asio::ip::tcp::socket socket(io_service);
+ ...
+ boost::asio::socket_base::linger option;
+ socket.get_option(option);
+ bool is_set = option.enabled();
+ unsigned short timeout = option.timeout();
 
-This function is used to check whether the socket input is currently positioned at the out-of-band data mark.
 
 
-[heading Parameters]
-
 
-[variablelist
-
-[[ec][Set to indicate what error occurred, if any.]]
 
-]
 
 
-[heading Return Value]
-
-A bool indicating whether the socket is at the out-of-band data mark.
+[heading Requirements]
 
+[*Header: ][^boost/asio/basic_seq_packet_socket.hpp]
 
+[*Convenience header: ][^boost/asio.hpp]
 
 
 [endsect]
 
 
-[endsect]
-
-[section:available basic_socket::available]
+[section:local_endpoint basic_seq_packet_socket::local_endpoint]
 
-[indexterm2 available..basic_socket]
-Determine the number of bytes available for reading.
+[indexterm2 local_endpoint..basic_seq_packet_socket]
+Get the local endpoint of the socket.
 
 
- std::size_t ``[link boost_asio.reference.basic_socket.available.overload1 available]``() const;
- `` [''''&raquo;''' [link boost_asio.reference.basic_socket.available.overload1 more...]]``
+ endpoint_type ``[link boost_asio.reference.basic_seq_packet_socket.local_endpoint.overload1 local_endpoint]``() const;
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.local_endpoint.overload1 more...]]``
 
- std::size_t ``[link boost_asio.reference.basic_socket.available.overload2 available]``(
+ endpoint_type ``[link boost_asio.reference.basic_seq_packet_socket.local_endpoint.overload2 local_endpoint]``(
       boost::system::error_code & ec) const;
- `` [''''&raquo;''' [link boost_asio.reference.basic_socket.available.overload2 more...]]``
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.local_endpoint.overload2 more...]]``
 
 
-[section:overload1 basic_socket::available (1 of 2 overloads)]
+[section:overload1 basic_seq_packet_socket::local_endpoint (1 of 2 overloads)]
 
 
-Determine the number of bytes available for reading.
+['Inherited from basic_socket.]
 
 
- std::size_t available() const;
+Get the local endpoint of the socket.
 
 
-This function is used to determine the number of bytes that may be read without blocking.
+ endpoint_type local_endpoint() const;
+
+
+This function is used to obtain the locally bound endpoint of the socket.
 
 
 [heading Return Value]
       
-The number of bytes that may be read without blocking, or 0 if an error occurs.
+An object that represents the local endpoint of the socket.
 
 
 [heading Exceptions]
@@ -15811,28 +17578,43 @@
 
 [variablelist
   
-[[boost::system::system_error][Thrown on failure. ]]
+[[boost::system::system_error][Thrown on failure.]]
 
 ]
 
 
+[heading Example]
+
+
+
+ boost::asio::ip::tcp::socket socket(io_service);
+ ...
+ boost::asio::ip::tcp::endpoint endpoint = socket.local_endpoint();
+
+
+
+
+
 
 
 [endsect]
 
 
 
-[section:overload2 basic_socket::available (2 of 2 overloads)]
+[section:overload2 basic_seq_packet_socket::local_endpoint (2 of 2 overloads)]
 
 
-Determine the number of bytes available for reading.
+['Inherited from basic_socket.]
 
 
- std::size_t available(
+Get the local endpoint of the socket.
+
+
+ endpoint_type local_endpoint(
       boost::system::error_code & ec) const;
 
 
-This function is used to determine the number of bytes that may be read without blocking.
+This function is used to obtain the locally bound endpoint of the socket.
 
 
 [heading Parameters]
@@ -15847,76 +17629,68 @@
 
 [heading Return Value]
       
-The number of bytes that may be read without blocking, or 0 if an error occurs.
-
+An object that represents the local endpoint of the socket. Returns a default-constructed endpoint object if an error occurred.
 
 
+[heading Example]
+
 
-[endsect]
 
+ boost::asio::ip::tcp::socket socket(io_service);
+ ...
+ boost::system::error_code ec;
+ boost::asio::ip::tcp::endpoint endpoint = socket.local_endpoint(ec);
+ if (ec)
+ {
+ // An error occurred.
+ }
 
-[endsect]
 
-[section:basic_socket basic_socket::basic_socket]
 
-[indexterm2 basic_socket..basic_socket]
-Construct a [link boost_asio.reference.basic_socket `basic_socket`] without opening it.
 
 
- explicit ``[link boost_asio.reference.basic_socket.basic_socket.overload1 basic_socket]``(
- boost::asio::io_service & io_service);
- `` [''''&raquo;''' [link boost_asio.reference.basic_socket.basic_socket.overload1 more...]]``
 
 
-Construct and open a [link boost_asio.reference.basic_socket `basic_socket`].
+[endsect]
 
 
- ``[link boost_asio.reference.basic_socket.basic_socket.overload2 basic_socket]``(
- boost::asio::io_service & io_service,
- const protocol_type & protocol);
- `` [''''&raquo;''' [link boost_asio.reference.basic_socket.basic_socket.overload2 more...]]``
+[endsect]
 
+[section:lowest_layer basic_seq_packet_socket::lowest_layer]
 
-Construct a [link boost_asio.reference.basic_socket `basic_socket`], opening it and binding it to the given local endpoint.
+[indexterm2 lowest_layer..basic_seq_packet_socket]
+Get a reference to the lowest layer.
 
 
- ``[link boost_asio.reference.basic_socket.basic_socket.overload3 basic_socket]``(
- boost::asio::io_service & io_service,
- const endpoint_type & endpoint);
- `` [''''&raquo;''' [link boost_asio.reference.basic_socket.basic_socket.overload3 more...]]``
+ lowest_layer_type & ``[link boost_asio.reference.basic_seq_packet_socket.lowest_layer.overload1 lowest_layer]``();
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.lowest_layer.overload1 more...]]``
 
 
-Construct a [link boost_asio.reference.basic_socket `basic_socket`] on an existing native socket.
+Get a const reference to the lowest layer.
 
 
- ``[link boost_asio.reference.basic_socket.basic_socket.overload4 basic_socket]``(
- boost::asio::io_service & io_service,
- const protocol_type & protocol,
- const native_type & native_socket);
- `` [''''&raquo;''' [link boost_asio.reference.basic_socket.basic_socket.overload4 more...]]``
+ const lowest_layer_type & ``[link boost_asio.reference.basic_seq_packet_socket.lowest_layer.overload2 lowest_layer]``() const;
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.lowest_layer.overload2 more...]]``
 
 
-[section:overload1 basic_socket::basic_socket (1 of 4 overloads)]
+[section:overload1 basic_seq_packet_socket::lowest_layer (1 of 2 overloads)]
 
 
-Construct a [link boost_asio.reference.basic_socket `basic_socket`] without opening it.
+['Inherited from basic_socket.]
 
 
- basic_socket(
- boost::asio::io_service & io_service);
+Get a reference to the lowest layer.
 
 
-This constructor creates a socket without opening it.
+ lowest_layer_type & lowest_layer();
 
 
-[heading Parameters]
-
+This function returns a reference to the lowest layer in a stack of layers. Since a [link boost_asio.reference.basic_socket `basic_socket`] cannot contain any further layers, it simply returns a reference to itself.
 
-[variablelist
-
-[[io_service][The [link boost_asio.reference.io_service `io_service`] object that the socket will use to dispatch handlers for any asynchronous operations performed on the socket. ]]
 
-]
+[heading Return Value]
+
+A reference to the lowest layer in the stack of layers. Ownership is not transferred to the caller.
 
 
 
@@ -15925,302 +17699,487 @@
 
 
 
-[section:overload2 basic_socket::basic_socket (2 of 4 overloads)]
-
-
-Construct and open a [link boost_asio.reference.basic_socket `basic_socket`].
-
+[section:overload2 basic_seq_packet_socket::lowest_layer (2 of 2 overloads)]
 
- basic_socket(
- boost::asio::io_service & io_service,
- const protocol_type & protocol);
 
+['Inherited from basic_socket.]
 
-This constructor creates and opens a socket.
 
+Get a const reference to the lowest layer.
 
-[heading Parameters]
-
 
-[variablelist
-
-[[io_service][The [link boost_asio.reference.io_service `io_service`] object that the socket will use to dispatch handlers for any asynchronous operations performed on the socket.]]
+ const lowest_layer_type & lowest_layer() const;
 
-[[protocol][An object specifying protocol parameters to be used.]]
 
-]
+This function returns a const reference to the lowest layer in a stack of layers. Since a [link boost_asio.reference.basic_socket `basic_socket`] cannot contain any further layers, it simply returns a reference to itself.
 
 
-[heading Exceptions]
-
+[heading Return Value]
+
+A const reference to the lowest layer in the stack of layers. Ownership is not transferred to the caller.
 
-[variablelist
-
-[[boost::system::system_error][Thrown on failure. ]]
 
-]
 
 
+[endsect]
 
 
 [endsect]
 
 
-
-[section:overload3 basic_socket::basic_socket (3 of 4 overloads)]
+[section:lowest_layer_type basic_seq_packet_socket::lowest_layer_type]
 
 
-Construct a [link boost_asio.reference.basic_socket `basic_socket`], opening it and binding it to the given local endpoint.
+['Inherited from basic_socket.]
 
+[indexterm2 lowest_layer_type..basic_seq_packet_socket]
+A [link boost_asio.reference.basic_socket `basic_socket`] is always the lowest layer.
 
- basic_socket(
- boost::asio::io_service & io_service,
- const endpoint_type & endpoint);
 
+ typedef basic_socket< Protocol, SeqPacketSocketService > lowest_layer_type;
 
-This constructor creates a socket and automatically opens it bound to the specified endpoint on the local machine. The protocol used is the protocol associated with the given endpoint.
 
+[heading Types]
+[table
+ [[Name][Description]]
 
-[heading Parameters]
-
+ [
 
-[variablelist
+ [[link boost_asio.reference.basic_socket.broadcast [*broadcast]]]
+ [Socket option to permit sending of broadcast messages. ]
   
-[[io_service][The [link boost_asio.reference.io_service `io_service`] object that the socket will use to dispatch handlers for any asynchronous operations performed on the socket.]]
-
-[[endpoint][An endpoint on the local machine to which the socket will be bound.]]
+ ]
 
-]
+ [
 
+ [[link boost_asio.reference.basic_socket.bytes_readable [*bytes_readable]]]
+ [IO control command to get the amount of data that can be read without blocking. ]
+
+ ]
 
-[heading Exceptions]
-
+ [
 
-[variablelist
+ [[link boost_asio.reference.basic_socket.debug [*debug]]]
+ [Socket option to enable socket-level debugging. ]
   
-[[boost::system::system_error][Thrown on failure. ]]
+ ]
 
-]
+ [
 
+ [[link boost_asio.reference.basic_socket.do_not_route [*do_not_route]]]
+ [Socket option to prevent routing, use local interfaces only. ]
+
+ ]
 
+ [
 
+ [[link boost_asio.reference.basic_socket.enable_connection_aborted [*enable_connection_aborted]]]
+ [Socket option to report aborted connections on accept. ]
+
+ ]
 
-[endsect]
+ [
 
+ [[link boost_asio.reference.basic_socket.endpoint_type [*endpoint_type]]]
+ [The endpoint type. ]
+
+ ]
 
+ [
 
-[section:overload4 basic_socket::basic_socket (4 of 4 overloads)]
+ [[link boost_asio.reference.basic_socket.implementation_type [*implementation_type]]]
+ [The underlying implementation type of I/O object. ]
+
+ ]
 
+ [
 
-Construct a [link boost_asio.reference.basic_socket `basic_socket`] on an existing native socket.
+ [[link boost_asio.reference.basic_socket.keep_alive [*keep_alive]]]
+ [Socket option to send keep-alives. ]
+
+ ]
 
+ [
 
- basic_socket(
- boost::asio::io_service & io_service,
- const protocol_type & protocol,
- const native_type & native_socket);
+ [[link boost_asio.reference.basic_socket.linger [*linger]]]
+ [Socket option to specify whether the socket lingers on close if unsent data is present. ]
+
+ ]
 
+ [
 
-This constructor creates a socket object to hold an existing native socket.
+ [[link boost_asio.reference.basic_socket.lowest_layer_type [*lowest_layer_type]]]
+ [A basic_socket is always the lowest layer. ]
+
+ ]
 
+ [
 
-[heading Parameters]
-
-
-[variablelist
+ [[link boost_asio.reference.basic_socket.message_flags [*message_flags]]]
+ [Bitmask type for flags that can be passed to send and receive operations. ]
   
-[[io_service][The [link boost_asio.reference.io_service `io_service`] object that the socket will use to dispatch handlers for any asynchronous operations performed on the socket.]]
+ ]
 
-[[protocol][An object specifying protocol parameters to be used.]]
+ [
 
-[[native_socket][A native socket.]]
+ [[link boost_asio.reference.basic_socket.native_handle_type [*native_handle_type]]]
+ [The native representation of a socket. ]
+
+ ]
 
-]
+ [
 
+ [[link boost_asio.reference.basic_socket.native_type [*native_type]]]
+ [(Deprecated: Use native_handle_type.) The native representation of a socket. ]
+
+ ]
 
-[heading Exceptions]
-
+ [
 
-[variablelist
+ [[link boost_asio.reference.basic_socket.non_blocking_io [*non_blocking_io]]]
+ [(Deprecated: Use non_blocking().) IO control command to set the blocking mode of the socket. ]
   
-[[boost::system::system_error][Thrown on failure. ]]
-
-]
+ ]
 
+ [
 
+ [[link boost_asio.reference.basic_socket.protocol_type [*protocol_type]]]
+ [The protocol type. ]
+
+ ]
 
+ [
 
-[endsect]
+ [[link boost_asio.reference.basic_socket.receive_buffer_size [*receive_buffer_size]]]
+ [Socket option for the receive buffer size of a socket. ]
+
+ ]
 
+ [
 
-[endsect]
+ [[link boost_asio.reference.basic_socket.receive_low_watermark [*receive_low_watermark]]]
+ [Socket option for the receive low watermark. ]
+
+ ]
 
-[section:bind basic_socket::bind]
+ [
 
-[indexterm2 bind..basic_socket]
-Bind the socket to the given local endpoint.
+ [[link boost_asio.reference.basic_socket.reuse_address [*reuse_address]]]
+ [Socket option to allow the socket to be bound to an address that is already in use. ]
+
+ ]
 
+ [
 
- void ``[link boost_asio.reference.basic_socket.bind.overload1 bind]``(
- const endpoint_type & endpoint);
- `` [''''&raquo;''' [link boost_asio.reference.basic_socket.bind.overload1 more...]]``
+ [[link boost_asio.reference.basic_socket.send_buffer_size [*send_buffer_size]]]
+ [Socket option for the send buffer size of a socket. ]
+
+ ]
 
- boost::system::error_code ``[link boost_asio.reference.basic_socket.bind.overload2 bind]``(
- const endpoint_type & endpoint,
- boost::system::error_code & ec);
- `` [''''&raquo;''' [link boost_asio.reference.basic_socket.bind.overload2 more...]]``
+ [
 
+ [[link boost_asio.reference.basic_socket.send_low_watermark [*send_low_watermark]]]
+ [Socket option for the send low watermark. ]
+
+ ]
 
-[section:overload1 basic_socket::bind (1 of 2 overloads)]
+ [
 
+ [[link boost_asio.reference.basic_socket.service_type [*service_type]]]
+ [The type of the service that will be used to provide I/O operations. ]
+
+ ]
 
-Bind the socket to the given local endpoint.
+ [
 
+ [[link boost_asio.reference.basic_socket.shutdown_type [*shutdown_type]]]
+ [Different ways a socket may be shutdown. ]
+
+ ]
 
- void bind(
- const endpoint_type & endpoint);
+]
 
+[heading Member Functions]
+[table
+ [[Name][Description]]
 
-This function binds the socket to the specified endpoint on the local machine.
+ [
+ [[link boost_asio.reference.basic_socket.assign [*assign]]]
+ [Assign an existing native socket to the socket. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_socket.async_connect [*async_connect]]]
+ [Start an asynchronous connect. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_socket.at_mark [*at_mark]]]
+ [Determine whether the socket is at the out-of-band data mark. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_socket.available [*available]]]
+ [Determine the number of bytes available for reading. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_socket.basic_socket [*basic_socket]]]
+ [Construct a basic_socket without opening it.
 
+ Construct and open a basic_socket.
 
-[heading Parameters]
-
+ Construct a basic_socket, opening it and binding it to the given local endpoint.
 
-[variablelist
+ Construct a basic_socket on an existing native socket. ]
+ ]
   
-[[endpoint][An endpoint on the local machine to which the socket will be bound.]]
-
-]
-
+ [
+ [[link boost_asio.reference.basic_socket.bind [*bind]]]
+ [Bind the socket to the given local endpoint. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_socket.cancel [*cancel]]]
+ [Cancel all asynchronous operations associated with the socket. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_socket.close [*close]]]
+ [Close the socket. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_socket.connect [*connect]]]
+ [Connect the socket to the specified endpoint. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_socket.get_io_service [*get_io_service]]]
+ [Get the io_service associated with the object. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_socket.get_option [*get_option]]]
+ [Get an option from the socket. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_socket.io_control [*io_control]]]
+ [Perform an IO control command on the socket. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_socket.is_open [*is_open]]]
+ [Determine whether the socket is open. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_socket.local_endpoint [*local_endpoint]]]
+ [Get the local endpoint of the socket. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_socket.lowest_layer [*lowest_layer]]]
+ [Get a reference to the lowest layer.
 
-[heading Exceptions]
-
+ Get a const reference to the lowest layer. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_socket.native [*native]]]
+ [(Deprecated: Use native_handle().) Get the native socket representation. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_socket.native_handle [*native_handle]]]
+ [Get the native socket representation. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_socket.native_non_blocking [*native_non_blocking]]]
+ [Gets the non-blocking mode of the native socket implementation.
 
-[variablelist
+ Sets the non-blocking mode of the native socket implementation. ]
+ ]
   
-[[boost::system::system_error][Thrown on failure.]]
+ [
+ [[link boost_asio.reference.basic_socket.non_blocking [*non_blocking]]]
+ [Gets the non-blocking mode of the socket.
 
+ Sets the non-blocking mode of the socket. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_socket.open [*open]]]
+ [Open the socket using the specified protocol. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_socket.remote_endpoint [*remote_endpoint]]]
+ [Get the remote endpoint of the socket. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_socket.set_option [*set_option]]]
+ [Set an option on the socket. ]
+ ]
+
+ [
+ [[link boost_asio.reference.basic_socket.shutdown [*shutdown]]]
+ [Disable sends or receives on the socket. ]
+ ]
+
 ]
 
+[heading Protected Member Functions]
+[table
+ [[Name][Description]]
 
-[heading Example]
+ [
+ [[link boost_asio.reference.basic_socket._basic_socket [*~basic_socket]]]
+ [Protected destructor to prevent deletion through this type. ]
+ ]
   
+]
 
+[heading Data Members]
+[table
+ [[Name][Description]]
 
- boost::asio::ip::tcp::socket socket(io_service);
- socket.open(boost::asio::ip::tcp::v4());
- socket.bind(boost::asio::ip::tcp::endpoint(
- boost::asio::ip::tcp::v4(), 12345));
+ [
+ [[link boost_asio.reference.basic_socket.max_connections [*max_connections]]]
+ [The maximum length of the queue of pending incoming connections. ]
+ ]
 
+ [
+ [[link boost_asio.reference.basic_socket.message_do_not_route [*message_do_not_route]]]
+ [Specify that the data should not be subject to routing. ]
+ ]
 
+ [
+ [[link boost_asio.reference.basic_socket.message_end_of_record [*message_end_of_record]]]
+ [Specifies that the data marks the end of a record. ]
+ ]
 
+ [
+ [[link boost_asio.reference.basic_socket.message_out_of_band [*message_out_of_band]]]
+ [Process out-of-band data. ]
+ ]
 
+ [
+ [[link boost_asio.reference.basic_socket.message_peek [*message_peek]]]
+ [Peek at incoming data without removing it from the input queue. ]
+ ]
 
+]
 
+[heading Protected Data Members]
+[table
+ [[Name][Description]]
 
-[endsect]
+ [
+ [[link boost_asio.reference.basic_socket.implementation [*implementation]]]
+ [The underlying implementation of the I/O object. ]
+ ]
 
+ [
+ [[link boost_asio.reference.basic_socket.service [*service]]]
+ [The service associated with the I/O object. ]
+ ]
 
+]
 
-[section:overload2 basic_socket::bind (2 of 2 overloads)]
+The [link boost_asio.reference.basic_socket `basic_socket`] class template provides functionality that is common to both stream-oriented and datagram-oriented sockets.
 
 
-Bind the socket to the given local endpoint.
+[heading Thread Safety]
+
+[*Distinct] [*objects:] Safe.
 
+[*Shared] [*objects:] Unsafe.
 
- boost::system::error_code bind(
- const endpoint_type & endpoint,
- boost::system::error_code & ec);
 
 
-This function binds the socket to the specified endpoint on the local machine.
 
+[heading Requirements]
 
-[heading Parameters]
-
+[*Header: ][^boost/asio/basic_seq_packet_socket.hpp]
 
-[variablelist
-
-[[endpoint][An endpoint on the local machine to which the socket will be bound.]]
+[*Convenience header: ][^boost/asio.hpp]
 
-[[ec][Set to indicate what error occurred, if any.]]
 
-]
+[endsect]
 
 
-[heading Example]
-
 
+[section:max_connections basic_seq_packet_socket::max_connections]
 
- boost::asio::ip::tcp::socket socket(io_service);
- socket.open(boost::asio::ip::tcp::v4());
- boost::system::error_code ec;
- socket.bind(boost::asio::ip::tcp::endpoint(
- boost::asio::ip::tcp::v4(), 12345), ec);
- if (ec)
- {
- // An error occurred.
- }
 
+['Inherited from socket_base.]
 
+[indexterm2 max_connections..basic_seq_packet_socket]
+The maximum length of the queue of pending incoming connections.
 
 
+ static const int max_connections = implementation_defined;
 
 
 
 [endsect]
 
 
-[endsect]
-
 
-[section:broadcast basic_socket::broadcast]
+[section:message_do_not_route basic_seq_packet_socket::message_do_not_route]
 
 
 ['Inherited from socket_base.]
 
-[indexterm2 broadcast..basic_socket]
-Socket option to permit sending of broadcast messages.
+[indexterm2 message_do_not_route..basic_seq_packet_socket]
+Specify that the data should not be subject to routing.
 
 
- typedef implementation_defined broadcast;
+ static const int message_do_not_route = implementation_defined;
 
 
 
-Implements the SOL\_SOCKET/SO\_BROADCAST socket option.
+[endsect]
 
 
-[heading Examples]
-
-Setting the option:
 
- boost::asio::ip::udp::socket socket(io_service);
- ...
- boost::asio::socket_base::broadcast option(true);
- socket.set_option(option);
+[section:message_end_of_record basic_seq_packet_socket::message_end_of_record]
 
 
+['Inherited from socket_base.]
 
+[indexterm2 message_end_of_record..basic_seq_packet_socket]
+Specifies that the data marks the end of a record.
 
 
-Getting the current option value:
+ static const int message_end_of_record = implementation_defined;
 
- boost::asio::ip::udp::socket socket(io_service);
- ...
- boost::asio::socket_base::broadcast option;
- socket.get_option(option);
- bool is_set = option.value();
+
+
+[endsect]
 
 
 
+[section:message_flags basic_seq_packet_socket::message_flags]
 
 
+['Inherited from socket_base.]
+
+[indexterm2 message_flags..basic_seq_packet_socket]
+Bitmask type for flags that can be passed to send and receive operations.
+
+
+ typedef int message_flags;
+
 
 
 [heading Requirements]
 
-[*Header: ][^boost/asio/basic_socket.hpp]
+[*Header: ][^boost/asio/basic_seq_packet_socket.hpp]
 
 [*Convenience header: ][^boost/asio.hpp]
 
@@ -16229,182 +18188,249 @@
 
 
 
-[section:bytes_readable basic_socket::bytes_readable]
+[section:message_out_of_band basic_seq_packet_socket::message_out_of_band]
 
 
 ['Inherited from socket_base.]
 
-[indexterm2 bytes_readable..basic_socket]
-IO control command to get the amount of data that can be read without blocking.
+[indexterm2 message_out_of_band..basic_seq_packet_socket]
+Process out-of-band data.
 
 
- typedef implementation_defined bytes_readable;
+ static const int message_out_of_band = implementation_defined;
 
 
 
-Implements the FIONREAD IO control command.
+[endsect]
 
 
-[heading Example]
-
 
+[section:message_peek basic_seq_packet_socket::message_peek]
 
- boost::asio::ip::tcp::socket socket(io_service);
- ...
- boost::asio::socket_base::bytes_readable command(true);
- socket.io_control(command);
- std::size_t bytes_readable = command.get();
 
+['Inherited from socket_base.]
 
+[indexterm2 message_peek..basic_seq_packet_socket]
+Peek at incoming data without removing it from the input queue.
 
 
+ static const int message_peek = implementation_defined;
 
 
 
-[heading Requirements]
+[endsect]
 
-[*Header: ][^boost/asio/basic_socket.hpp]
 
-[*Convenience header: ][^boost/asio.hpp]
 
+[section:native basic_seq_packet_socket::native]
 
-[endsect]
 
+['Inherited from basic_socket.]
 
-[section:cancel basic_socket::cancel]
+[indexterm2 native..basic_seq_packet_socket]
+(Deprecated: Use `native_handle()`.) Get the native socket representation.
 
-[indexterm2 cancel..basic_socket]
-Cancel all asynchronous operations associated with the socket.
 
+ native_type native();
 
- void ``[link boost_asio.reference.basic_socket.cancel.overload1 cancel]``();
- `` [''''&raquo;''' [link boost_asio.reference.basic_socket.cancel.overload1 more...]]``
 
- boost::system::error_code ``[link boost_asio.reference.basic_socket.cancel.overload2 cancel]``(
- boost::system::error_code & ec);
- `` [''''&raquo;''' [link boost_asio.reference.basic_socket.cancel.overload2 more...]]``
+This function may be used to obtain the underlying representation of the socket. This is intended to allow access to native socket functionality that is not otherwise provided.
 
 
-[section:overload1 basic_socket::cancel (1 of 2 overloads)]
+[endsect]
 
 
-Cancel all asynchronous operations associated with the socket.
 
+[section:native_handle basic_seq_packet_socket::native_handle]
 
- void cancel();
 
+['Inherited from basic_socket.]
 
-This function causes all outstanding asynchronous connect, send and receive operations to finish immediately, and the handlers for cancelled operations will be passed the `boost::asio::error::operation_aborted` error.
+[indexterm2 native_handle..basic_seq_packet_socket]
+Get the native socket representation.
 
 
-[heading Exceptions]
-
+ native_handle_type native_handle();
 
-[variablelist
-
-[[boost::system::system_error][Thrown on failure.]]
 
-]
+This function may be used to obtain the underlying representation of the socket. This is intended to allow access to native socket functionality that is not otherwise provided.
 
 
-[heading Remarks]
-
-Calls to `cancel()` will always fail with `boost::asio::error::operation_not_supported` when run on Windows XP, Windows Server 2003, and earlier versions of Windows, unless BOOST\_ASIO\_ENABLE\_CANCELIO is defined. However, the CancelIo function has two issues that should be considered before enabling its use:
+[endsect]
 
 
-* It will only cancel asynchronous operations that were initiated in the current thread.
 
+[section:native_handle_type basic_seq_packet_socket::native_handle_type]
 
-* It can appear to complete without error, but the request to cancel the unfinished operations may be silently ignored by the operating system. Whether it works or not seems to depend on the drivers that are installed.
+[indexterm2 native_handle_type..basic_seq_packet_socket]
+The native representation of a socket.
 
-For portable cancellation, consider using one of the following alternatives:
 
+ typedef SeqPacketSocketService::native_handle_type native_handle_type;
 
-* Disable asio's I/O completion port backend by defining BOOST\_ASIO\_DISABLE\_IOCP.
 
 
-* Use the `close()` function to simultaneously cancel the outstanding operations and close the socket.
+[heading Requirements]
 
-When running on Windows Vista, Windows Server 2008, and later, the CancelIoEx function is always used. This function does not have the problems described above.
+[*Header: ][^boost/asio/basic_seq_packet_socket.hpp]
+
+[*Convenience header: ][^boost/asio.hpp]
 
 
 [endsect]
 
 
+[section:native_non_blocking basic_seq_packet_socket::native_non_blocking]
 
-[section:overload2 basic_socket::cancel (2 of 2 overloads)]
+[indexterm2 native_non_blocking..basic_seq_packet_socket]
+Gets the non-blocking mode of the native socket implementation.
 
 
-Cancel all asynchronous operations associated with the socket.
+ bool ``[link boost_asio.reference.basic_seq_packet_socket.native_non_blocking.overload1 native_non_blocking]``() const;
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.native_non_blocking.overload1 more...]]``
 
 
- boost::system::error_code cancel(
+Sets the non-blocking mode of the native socket implementation.
+
+
+ void ``[link boost_asio.reference.basic_seq_packet_socket.native_non_blocking.overload2 native_non_blocking]``(
+ bool mode);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.native_non_blocking.overload2 more...]]``
+
+ boost::system::error_code ``[link boost_asio.reference.basic_seq_packet_socket.native_non_blocking.overload3 native_non_blocking]``(
+ bool mode,
       boost::system::error_code & ec);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.native_non_blocking.overload3 more...]]``
 
 
-This function causes all outstanding asynchronous connect, send and receive operations to finish immediately, and the handlers for cancelled operations will be passed the `boost::asio::error::operation_aborted` error.
+[section:overload1 basic_seq_packet_socket::native_non_blocking (1 of 3 overloads)]
 
 
-[heading Parameters]
-
+['Inherited from basic_socket.]
 
-[variablelist
-
-[[ec][Set to indicate what error occurred, if any.]]
 
-]
+Gets the non-blocking mode of the native socket implementation.
+
+
+ bool native_non_blocking() const;
+
+
+This function is used to retrieve the non-blocking mode of the underlying native socket. This mode has no effect on the behaviour of the socket object's synchronous operations.
+
+
+[heading Return Value]
+
+`true` if the underlying socket is in non-blocking mode and direct system calls may fail with `boost::asio::error::would_block` (or the equivalent system error).
 
 
 [heading Remarks]
       
-Calls to `cancel()` will always fail with `boost::asio::error::operation_not_supported` when run on Windows XP, Windows Server 2003, and earlier versions of Windows, unless BOOST\_ASIO\_ENABLE\_CANCELIO is defined. However, the CancelIo function has two issues that should be considered before enabling its use:
+The current non-blocking mode is cached by the socket object. Consequently, the return value may be incorrect if the non-blocking mode was set directly on the native socket.
 
 
-* It will only cancel asynchronous operations that were initiated in the current thread.
+[heading Example]
+
+This function is 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 following example illustrates how Linux's `sendfile` system call might be encapsulated:
 
+ template <typename Handler>
+ struct sendfile_op
+ {
+ tcp::socket& sock_;
+ int fd_;
+ Handler handler_;
+ off_t offset_;
+ std::size_t total_bytes_transferred_;
+
+ // Function call operator meeting WriteHandler requirements.
+ // Used as the handler for the async_write_some operation.
+ void operator()(boost::system::error_code ec, std::size_t)
+ {
+ // Put the underlying socket into non-blocking mode.
+ if (!ec)
+ if (!sock_.native_non_blocking())
+ sock_.native_non_blocking(true, ec);
+
+ if (!ec)
+ {
+ for (;;)
+ {
+ // Try the system call.
+ errno = 0;
+ int n = ::sendfile(sock_.native_handle(), fd_, &offset_, 65536);
+ ec = boost::system::error_code(n < 0 ? errno : 0,
+ boost::asio::error::get_system_category());
+ total_bytes_transferred_ += ec ? 0 : n;
+
+ // Retry operation immediately if interrupted by signal.
+ if (ec == boost::asio::error::interrupted)
+ continue;
+
+ // Check if we need to run the operation again.
+ if (ec == boost::asio::error::would_block
+ || ec == boost::asio::error::try_again)
+ {
+ // We have to wait for the socket to become ready again.
+ sock_.async_write_some(boost::asio::null_buffers(), *this);
+ return;
+ }
+
+ if (ec || n == 0)
+ {
+ // An error occurred, or we have reached the end of the file.
+ // Either way we must exit the loop so we can call the handler.
+ break;
+ }
+
+ // Loop around to try calling sendfile again.
+ }
+ }
 
-* It can appear to complete without error, but the request to cancel the unfinished operations may be silently ignored by the operating system. Whether it works or not seems to depend on the drivers that are installed.
+ // Pass result back to user's handler.
+ handler_(ec, total_bytes_transferred_);
+ }
+ };
 
-For portable cancellation, consider using one of the following alternatives:
+ template <typename Handler>
+ void async_sendfile(tcp::socket& sock, int fd, Handler h)
+ {
+ sendfile_op<Handler> op = { sock, fd, h, 0, 0 };
+ sock.async_write_some(boost::asio::null_buffers(), op);
+ }
 
 
-* Disable asio's I/O completion port backend by defining BOOST\_ASIO\_DISABLE\_IOCP.
 
 
-* Use the `close()` function to simultaneously cancel the outstanding operations and close the socket.
 
-When running on Windows Vista, Windows Server 2008, and later, the CancelIoEx function is always used. This function does not have the problems described above.
 
 
 [endsect]
 
 
-[endsect]
 
-[section:close basic_socket::close]
+[section:overload2 basic_seq_packet_socket::native_non_blocking (2 of 3 overloads)]
 
-[indexterm2 close..basic_socket]
-Close the socket.
 
+['Inherited from basic_socket.]
 
- void ``[link boost_asio.reference.basic_socket.close.overload1 close]``();
- `` [''''&raquo;''' [link boost_asio.reference.basic_socket.close.overload1 more...]]``
 
- boost::system::error_code ``[link boost_asio.reference.basic_socket.close.overload2 close]``(
- boost::system::error_code & ec);
- `` [''''&raquo;''' [link boost_asio.reference.basic_socket.close.overload2 more...]]``
+Sets the non-blocking mode of the native socket implementation.
 
 
-[section:overload1 basic_socket::close (1 of 2 overloads)]
+ void native_non_blocking(
+ bool mode);
 
 
-Close the socket.
+This function is used to modify the non-blocking mode of the underlying native socket. It has no effect on the behaviour of the socket object's synchronous operations.
 
 
- void close();
+[heading Parameters]
+
 
+[variablelist
+
+[[mode][If `true`, the underlying socket is put into non-blocking mode and direct system calls may fail with `boost::asio::error::would_block` (or the equivalent system error).]]
 
-This function is used to close the socket. Any asynchronous send, receive or connect operations will be cancelled immediately, and will complete with the `boost::asio::error::operation_aborted` error.
+]
 
 
 [heading Exceptions]
@@ -16412,14 +18438,82 @@
 
 [variablelist
   
-[[boost::system::system_error][Thrown on failure.]]
+[[boost::system::system_error][Thrown on failure. If the `mode` is `false`, but the current value of `non_blocking()` is `true`, this function fails with `boost::asio::error::invalid_argument`, as the combination does not make sense.]]
 
 ]
 
 
-[heading Remarks]
-
-For portable behaviour with respect to graceful closure of a connected socket, call `shutdown()` before closing the socket.
+[heading Example]
+
+This function is 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 following example illustrates how Linux's `sendfile` system call might be encapsulated:
+
+ template <typename Handler>
+ struct sendfile_op
+ {
+ tcp::socket& sock_;
+ int fd_;
+ Handler handler_;
+ off_t offset_;
+ std::size_t total_bytes_transferred_;
+
+ // Function call operator meeting WriteHandler requirements.
+ // Used as the handler for the async_write_some operation.
+ void operator()(boost::system::error_code ec, std::size_t)
+ {
+ // Put the underlying socket into non-blocking mode.
+ if (!ec)
+ if (!sock_.native_non_blocking())
+ sock_.native_non_blocking(true, ec);
+
+ if (!ec)
+ {
+ for (;;)
+ {
+ // Try the system call.
+ errno = 0;
+ int n = ::sendfile(sock_.native_handle(), fd_, &offset_, 65536);
+ ec = boost::system::error_code(n < 0 ? errno : 0,
+ boost::asio::error::get_system_category());
+ total_bytes_transferred_ += ec ? 0 : n;
+
+ // Retry operation immediately if interrupted by signal.
+ if (ec == boost::asio::error::interrupted)
+ continue;
+
+ // Check if we need to run the operation again.
+ if (ec == boost::asio::error::would_block
+ || ec == boost::asio::error::try_again)
+ {
+ // We have to wait for the socket to become ready again.
+ sock_.async_write_some(boost::asio::null_buffers(), *this);
+ return;
+ }
+
+ if (ec || n == 0)
+ {
+ // An error occurred, or we have reached the end of the file.
+ // Either way we must exit the loop so we can call the handler.
+ break;
+ }
+
+ // Loop around to try calling sendfile again.
+ }
+ }
+
+ // Pass result back to user's handler.
+ handler_(ec, total_bytes_transferred_);
+ }
+ };
+
+ template <typename Handler>
+ void async_sendfile(tcp::socket& sock, int fd, Handler h)
+ {
+ sendfile_op<Handler> op = { sock, fd, h, 0, 0 };
+ sock.async_write_some(boost::asio::null_buffers(), op);
+ }
+
+
+
 
 
 
@@ -16428,17 +18522,21 @@
 
 
 
-[section:overload2 basic_socket::close (2 of 2 overloads)]
+[section:overload3 basic_seq_packet_socket::native_non_blocking (3 of 3 overloads)]
 
 
-Close the socket.
+['Inherited from basic_socket.]
 
 
- boost::system::error_code close(
+Sets the non-blocking mode of the native socket implementation.
+
+
+ boost::system::error_code native_non_blocking(
+ bool mode,
       boost::system::error_code & ec);
 
 
-This function is used to close the socket. Any asynchronous send, receive or connect operations will be cancelled immediately, and will complete with the `boost::asio::error::operation_aborted` error.
+This function is used to modify the non-blocking mode of the underlying native socket. It has no effect on the behaviour of the socket object's synchronous operations.
 
 
 [heading Parameters]
@@ -16446,31 +18544,84 @@
 
 [variablelist
   
-[[ec][Set to indicate what error occurred, if any.]]
+[[mode][If `true`, the underlying socket is put into non-blocking mode and direct system calls may fail with `boost::asio::error::would_block` (or the equivalent system error).]]
+
+[[ec][Set to indicate what error occurred, if any. If the `mode` is `false`, but the current value of `non_blocking()` is `true`, this function fails with `boost::asio::error::invalid_argument`, as the combination does not make sense.]]
 
 ]
 
 
 [heading Example]
   
+This function is 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 following example illustrates how Linux's `sendfile` system call might be encapsulated:
 
-
- boost::asio::ip::tcp::socket socket(io_service);
- ...
- boost::system::error_code ec;
- socket.close(ec);
- if (ec)
+ template <typename Handler>
+ struct sendfile_op
    {
- // An error occurred.
- }
+ tcp::socket& sock_;
+ int fd_;
+ Handler handler_;
+ off_t offset_;
+ std::size_t total_bytes_transferred_;
+
+ // Function call operator meeting WriteHandler requirements.
+ // Used as the handler for the async_write_some operation.
+ void operator()(boost::system::error_code ec, std::size_t)
+ {
+ // Put the underlying socket into non-blocking mode.
+ if (!ec)
+ if (!sock_.native_non_blocking())
+ sock_.native_non_blocking(true, ec);
+
+ if (!ec)
+ {
+ for (;;)
+ {
+ // Try the system call.
+ errno = 0;
+ int n = ::sendfile(sock_.native_handle(), fd_, &offset_, 65536);
+ ec = boost::system::error_code(n < 0 ? errno : 0,
+ boost::asio::error::get_system_category());
+ total_bytes_transferred_ += ec ? 0 : n;
+
+ // Retry operation immediately if interrupted by signal.
+ if (ec == boost::asio::error::interrupted)
+ continue;
+
+ // Check if we need to run the operation again.
+ if (ec == boost::asio::error::would_block
+ || ec == boost::asio::error::try_again)
+ {
+ // We have to wait for the socket to become ready again.
+ sock_.async_write_some(boost::asio::null_buffers(), *this);
+ return;
+ }
+
+ if (ec || n == 0)
+ {
+ // An error occurred, or we have reached the end of the file.
+ // Either way we must exit the loop so we can call the handler.
+ break;
+ }
+
+ // Loop around to try calling sendfile again.
+ }
+ }
 
+ // Pass result back to user's handler.
+ handler_(ec, total_bytes_transferred_);
+ }
+ };
 
+ template <typename Handler>
+ void async_sendfile(tcp::socket& sock, int fd, Handler h)
+ {
+ sendfile_op<Handler> op = { sock, fd, h, 0, 0 };
+ sock.async_write_some(boost::asio::null_buffers(), op);
+ }
 
 
 
-[heading Remarks]
-
-For portable behaviour with respect to graceful closure of a connected socket, call `shutdown()` before closing the socket.
 
 
 
@@ -16480,120 +18631,71 @@
 
 [endsect]
 
-[section:connect basic_socket::connect]
 
-[indexterm2 connect..basic_socket]
-Connect the socket to the specified endpoint.
+[section:native_type basic_seq_packet_socket::native_type]
 
+[indexterm2 native_type..basic_seq_packet_socket]
+(Deprecated: Use native\_handle\_type.) The native representation of a socket.
 
- void ``[link boost_asio.reference.basic_socket.connect.overload1 connect]``(
- const endpoint_type & peer_endpoint);
- `` [''''&raquo;''' [link boost_asio.reference.basic_socket.connect.overload1 more...]]``
 
- boost::system::error_code ``[link boost_asio.reference.basic_socket.connect.overload2 connect]``(
- const endpoint_type & peer_endpoint,
- boost::system::error_code & ec);
- `` [''''&raquo;''' [link boost_asio.reference.basic_socket.connect.overload2 more...]]``
+ typedef SeqPacketSocketService::native_handle_type native_type;
 
 
-[section:overload1 basic_socket::connect (1 of 2 overloads)]
 
+[heading Requirements]
 
-Connect the socket to the specified endpoint.
+[*Header: ][^boost/asio/basic_seq_packet_socket.hpp]
 
+[*Convenience header: ][^boost/asio.hpp]
 
- void connect(
- const endpoint_type & peer_endpoint);
 
+[endsect]
 
-This function is used to connect a socket to the specified remote endpoint. The function call will block until the connection is successfully made or an error occurs.
 
-The socket is automatically opened if it is not already open. If the connect fails, and the socket was automatically opened, the socket is not returned to the closed state.
+[section:non_blocking basic_seq_packet_socket::non_blocking]
 
+[indexterm2 non_blocking..basic_seq_packet_socket]
+Gets the non-blocking mode of the socket.
 
-[heading Parameters]
-
 
-[variablelist
-
-[[peer_endpoint][The remote endpoint to which the socket will be connected.]]
+ bool ``[link boost_asio.reference.basic_seq_packet_socket.non_blocking.overload1 non_blocking]``() const;
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.non_blocking.overload1 more...]]``
 
-]
 
+Sets the non-blocking mode of the socket.
 
-[heading Exceptions]
-
-
-[variablelist
-
-[[boost::system::system_error][Thrown on failure.]]
-
-]
-
-
-[heading Example]
-
-
-
- boost::asio::ip::tcp::socket socket(io_service);
- boost::asio::ip::tcp::endpoint endpoint(
- boost::asio::ip::address::from_string("1.2.3.4"), 12345);
- socket.connect(endpoint);
-
-
-
-
-
-
-
-[endsect]
-
-
-
-[section:overload2 basic_socket::connect (2 of 2 overloads)]
-
-
-Connect the socket to the specified endpoint.
 
+ void ``[link boost_asio.reference.basic_seq_packet_socket.non_blocking.overload2 non_blocking]``(
+ bool mode);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.non_blocking.overload2 more...]]``
 
- boost::system::error_code connect(
- const endpoint_type & peer_endpoint,
+ boost::system::error_code ``[link boost_asio.reference.basic_seq_packet_socket.non_blocking.overload3 non_blocking]``(
+ bool mode,
       boost::system::error_code & ec);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.non_blocking.overload3 more...]]``
 
 
-This function is used to connect a socket to the specified remote endpoint. The function call will block until the connection is successfully made or an error occurs.
-
-The socket is automatically opened if it is not already open. If the connect fails, and the socket was automatically opened, the socket is not returned to the closed state.
-
+[section:overload1 basic_seq_packet_socket::non_blocking (1 of 3 overloads)]
 
-[heading Parameters]
-
 
-[variablelist
-
-[[peer_endpoint][The remote endpoint to which the socket will be connected.]]
+['Inherited from basic_socket.]
 
-[[ec][Set to indicate what error occurred, if any.]]
 
-]
+Gets the non-blocking mode of the socket.
 
 
-[heading Example]
-
+ bool non_blocking() const;
 
 
- boost::asio::ip::tcp::socket socket(io_service);
- boost::asio::ip::tcp::endpoint endpoint(
- boost::asio::ip::address::from_string("1.2.3.4"), 12345);
- boost::system::error_code ec;
- socket.connect(endpoint, ec);
- if (ec)
- {
- // An error occurred.
- }
 
+[heading Return Value]
+
+`true` if the socket's synchronous operations will fail with `boost::asio::error::would_block` if they are unable to perform the requested operation immediately. If `false`, synchronous operations will block until complete.
 
 
+[heading Remarks]
+
+The non-blocking mode has no effect on the behaviour of asynchronous operations. Asynchronous operations will never fail with the error `boost::asio::error::would_block`.
 
 
 
@@ -16601,184 +18703,126 @@
 [endsect]
 
 
-[endsect]
-
 
-[section:debug basic_socket::debug]
+[section:overload2 basic_seq_packet_socket::non_blocking (2 of 3 overloads)]
 
 
-['Inherited from socket_base.]
+['Inherited from basic_socket.]
 
-[indexterm2 debug..basic_socket]
-Socket option to enable socket-level debugging.
 
+Sets the non-blocking mode of the socket.
 
- typedef implementation_defined debug;
 
+ void non_blocking(
+ bool mode);
 
 
-Implements the SOL\_SOCKET/SO\_DEBUG socket option.
 
+[heading Parameters]
+
 
-[heading Examples]
+[variablelist
   
-Setting the option:
-
- boost::asio::ip::tcp::socket socket(io_service);
- ...
- boost::asio::socket_base::debug option(true);
- socket.set_option(option);
-
-
-
-
-
-Getting the current option value:
-
- boost::asio::ip::tcp::socket socket(io_service);
- ...
- boost::asio::socket_base::debug option;
- socket.get_option(option);
- bool is_set = option.value();
+[[mode][If `true`, the socket's synchronous operations will fail with `boost::asio::error::would_block` if they are unable to perform the requested operation immediately. If `false`, synchronous operations will block until complete.]]
 
+]
 
 
+[heading Exceptions]
+
 
+[variablelist
+
+[[boost::system::system_error][Thrown on failure.]]
 
+]
 
 
-[heading Requirements]
+[heading Remarks]
+
+The non-blocking mode has no effect on the behaviour of asynchronous operations. Asynchronous operations will never fail with the error `boost::asio::error::would_block`.
 
-[*Header: ][^boost/asio/basic_socket.hpp]
 
-[*Convenience header: ][^boost/asio.hpp]
 
 
 [endsect]
 
 
 
-[section:do_not_route basic_socket::do_not_route]
+[section:overload3 basic_seq_packet_socket::non_blocking (3 of 3 overloads)]
 
 
-['Inherited from socket_base.]
+['Inherited from basic_socket.]
 
-[indexterm2 do_not_route..basic_socket]
-Socket option to prevent routing, use local interfaces only.
 
+Sets the non-blocking mode of the socket.
 
- typedef implementation_defined do_not_route;
 
+ boost::system::error_code non_blocking(
+ bool mode,
+ boost::system::error_code & ec);
 
 
-Implements the SOL\_SOCKET/SO\_DONTROUTE socket option.
 
+[heading Parameters]
+
 
-[heading Examples]
+[variablelist
   
-Setting the option:
-
- boost::asio::ip::udp::socket socket(io_service);
- ...
- boost::asio::socket_base::do_not_route option(true);
- socket.set_option(option);
-
-
-
-
-
-Getting the current option value:
-
- boost::asio::ip::udp::socket socket(io_service);
- ...
- boost::asio::socket_base::do_not_route option;
- socket.get_option(option);
- bool is_set = option.value();
-
+[[mode][If `true`, the socket's synchronous operations will fail with `boost::asio::error::would_block` if they are unable to perform the requested operation immediately. If `false`, synchronous operations will block until complete.]]
 
+[[ec][Set to indicate what error occurred, if any.]]
 
+]
 
 
+[heading Remarks]
+
+The non-blocking mode has no effect on the behaviour of asynchronous operations. Asynchronous operations will never fail with the error `boost::asio::error::would_block`.
 
 
-[heading Requirements]
 
-[*Header: ][^boost/asio/basic_socket.hpp]
 
-[*Convenience header: ][^boost/asio.hpp]
+[endsect]
 
 
 [endsect]
 
 
-
-[section:enable_connection_aborted basic_socket::enable_connection_aborted]
+[section:non_blocking_io basic_seq_packet_socket::non_blocking_io]
 
 
 ['Inherited from socket_base.]
 
-[indexterm2 enable_connection_aborted..basic_socket]
-Socket option to report aborted connections on accept.
+[indexterm2 non_blocking_io..basic_seq_packet_socket]
+(Deprecated: Use non\_blocking().) IO control command to set the blocking mode of the socket.
 
 
- typedef implementation_defined enable_connection_aborted;
+ typedef implementation_defined non_blocking_io;
 
 
 
-Implements a custom socket option that determines whether or not an accept operation is permitted to fail with `boost::asio::error::connection_aborted`. By default the option is false.
+Implements the FIONBIO IO control command.
 
 
-[heading Examples]
+[heading Example]
   
-Setting the option:
-
- boost::asio::ip::tcp::acceptor acceptor(io_service);
- ...
- boost::asio::socket_base::enable_connection_aborted option(true);
- acceptor.set_option(option);
-
 
 
-
-
-Getting the current option value:
-
- boost::asio::ip::tcp::acceptor acceptor(io_service);
+ boost::asio::ip::tcp::socket socket(io_service);
    ...
- boost::asio::socket_base::enable_connection_aborted option;
- acceptor.get_option(option);
- bool is_set = option.value();
-
-
-
-
-
-
-
-[heading Requirements]
-
-[*Header: ][^boost/asio/basic_socket.hpp]
-
-[*Convenience header: ][^boost/asio.hpp]
-
-
-[endsect]
-
-
+ boost::asio::socket_base::non_blocking_io command(true);
+ socket.io_control(command);
 
-[section:endpoint_type basic_socket::endpoint_type]
 
-[indexterm2 endpoint_type..basic_socket]
-The endpoint type.
 
 
- typedef Protocol::endpoint endpoint_type;
 
 
 
 [heading Requirements]
 
-[*Header: ][^boost/asio/basic_socket.hpp]
+[*Header: ][^boost/asio/basic_seq_packet_socket.hpp]
 
 [*Convenience header: ][^boost/asio.hpp]
 
@@ -16786,65 +18830,36 @@
 [endsect]
 
 
+[section:open basic_seq_packet_socket::open]
 
-[section:get_io_service basic_socket::get_io_service]
-
-
-['Inherited from basic_io_object.]
-
-[indexterm2 get_io_service..basic_socket]
-Get the [link boost_asio.reference.io_service `io_service`] associated with the object.
-
-
- boost::asio::io_service & get_io_service();
-
-
-This function may be used to obtain the [link boost_asio.reference.io_service `io_service`] object that the I/O object uses to dispatch handlers for asynchronous operations.
-
-
-[heading Return Value]
-
-A reference to the [link boost_asio.reference.io_service `io_service`] object that the I/O object will use to dispatch handlers. Ownership is not transferred to the caller.
-
-
-
-
-[endsect]
-
+[indexterm2 open..basic_seq_packet_socket]
+Open the socket using the specified protocol.
 
-[section:get_option basic_socket::get_option]
 
-[indexterm2 get_option..basic_socket]
-Get an option from the socket.
+ void ``[link boost_asio.reference.basic_seq_packet_socket.open.overload1 open]``(
+ const protocol_type & protocol = protocol_type());
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.open.overload1 more...]]``
 
+ boost::system::error_code ``[link boost_asio.reference.basic_seq_packet_socket.open.overload2 open]``(
+ const protocol_type & protocol,
+ boost::system::error_code & ec);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.open.overload2 more...]]``
 
- template<
- typename ``[link boost_asio.reference.GettableSocketOption GettableSocketOption]``>
- void ``[link boost_asio.reference.basic_socket.get_option.overload1 get_option]``(
- GettableSocketOption & option) const;
- `` [''''&raquo;''' [link boost_asio.reference.basic_socket.get_option.overload1 more...]]``
 
- template<
- typename ``[link boost_asio.reference.GettableSocketOption GettableSocketOption]``>
- boost::system::error_code ``[link boost_asio.reference.basic_socket.get_option.overload2 get_option]``(
- GettableSocketOption & option,
- boost::system::error_code & ec) const;
- `` [''''&raquo;''' [link boost_asio.reference.basic_socket.get_option.overload2 more...]]``
+[section:overload1 basic_seq_packet_socket::open (1 of 2 overloads)]
 
 
-[section:overload1 basic_socket::get_option (1 of 2 overloads)]
+['Inherited from basic_socket.]
 
 
-Get an option from the socket.
+Open the socket using the specified protocol.
 
 
- template<
- typename ``[link boost_asio.reference.GettableSocketOption GettableSocketOption]``>
- void get_option(
- GettableSocketOption & option) const;
+ void open(
+ const protocol_type & protocol = protocol_type());
 
 
-This function is used to get the current value of an option on the socket.
+This function opens the socket so that it will use the specified protocol.
 
 
 [heading Parameters]
@@ -16852,7 +18867,7 @@
 
 [variablelist
   
-[[option][The option value to be obtained from the socket.]]
+[[protocol][An object specifying protocol parameters to be used.]]
 
 ]
 
@@ -16867,16 +18882,12 @@
 ]
 
 
-
 [heading Example]
   
-Getting the value of the SOL\_SOCKET/SO\_KEEPALIVE option:
+
 
    boost::asio::ip::tcp::socket socket(io_service);
- ...
- boost::asio::ip::tcp::socket::keep_alive option;
- socket.get_option(option);
- bool is_set = option.get();
+ socket.open(boost::asio::ip::tcp::v4());
 
 
 
@@ -16888,20 +18899,21 @@
 
 
 
-[section:overload2 basic_socket::get_option (2 of 2 overloads)]
+[section:overload2 basic_seq_packet_socket::open (2 of 2 overloads)]
 
 
-Get an option from the socket.
+['Inherited from basic_socket.]
 
 
- template<
- typename ``[link boost_asio.reference.GettableSocketOption GettableSocketOption]``>
- boost::system::error_code get_option(
- GettableSocketOption & option,
- boost::system::error_code & ec) const;
+Open the socket using the specified protocol.
 
 
-This function is used to get the current value of an option on the socket.
+ boost::system::error_code open(
+ const protocol_type & protocol,
+ boost::system::error_code & ec);
+
+
+This function opens the socket so that it will use the specified protocol.
 
 
 [heading Parameters]
@@ -16909,74 +18921,50 @@
 
 [variablelist
   
-[[option][The option value to be obtained from the socket.]]
+[[protocol][An object specifying which protocol is to be used.]]
 
 [[ec][Set to indicate what error occurred, if any.]]
 
 ]
 
 
-
 [heading Example]
   
-Getting the value of the SOL\_SOCKET/SO\_KEEPALIVE option:
+
 
    boost::asio::ip::tcp::socket socket(io_service);
- ...
- boost::asio::ip::tcp::socket::keep_alive option;
    boost::system::error_code ec;
- socket.get_option(option, ec);
+ socket.open(boost::asio::ip::tcp::v4(), ec);
    if (ec)
    {
      // An error occurred.
    }
- bool is_set = option.get();
-
 
 
 
 
 
 
-[endsect]
-
 
 [endsect]
 
 
-[section:implementation basic_socket::implementation]
-
-
-['Inherited from basic_io_object.]
-
-[indexterm2 implementation..basic_socket]
-The underlying implementation of the I/O object.
-
-
- implementation_type implementation;
-
-
-
 [endsect]
 
 
+[section:protocol_type basic_seq_packet_socket::protocol_type]
 
-[section:implementation_type basic_socket::implementation_type]
-
-
-['Inherited from basic_io_object.]
-
-[indexterm2 implementation_type..basic_socket]
-The underlying implementation type of I/O object.
+[indexterm2 protocol_type..basic_seq_packet_socket]
+The protocol type.
 
 
- typedef service_type::implementation_type implementation_type;
+ typedef Protocol protocol_type;
 
 
 
 [heading Requirements]
 
-[*Header: ][^boost/asio/basic_socket.hpp]
+[*Header: ][^boost/asio/basic_seq_packet_socket.hpp]
 
 [*Convenience header: ][^boost/asio.hpp]
 
@@ -16984,39 +18972,55 @@
 [endsect]
 
 
-[section:io_control basic_socket::io_control]
+[section:receive basic_seq_packet_socket::receive]
 
-[indexterm2 io_control..basic_socket]
-Perform an IO control command on the socket.
+[indexterm2 receive..basic_seq_packet_socket]
+Receive some data on the socket.
 
 
   template<
- typename ``[link boost_asio.reference.IoControlCommand IoControlCommand]``>
- void ``[link boost_asio.reference.basic_socket.io_control.overload1 io_control]``(
- IoControlCommand & command);
- `` [''''&raquo;''' [link boost_asio.reference.basic_socket.io_control.overload1 more...]]``
+ typename ``[link boost_asio.reference.MutableBufferSequence MutableBufferSequence]``>
+ std::size_t ``[link boost_asio.reference.basic_seq_packet_socket.receive.overload1 receive]``(
+ const MutableBufferSequence & buffers,
+ socket_base::message_flags & out_flags);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.receive.overload1 more...]]``
 
   template<
- typename ``[link boost_asio.reference.IoControlCommand IoControlCommand]``>
- boost::system::error_code ``[link boost_asio.reference.basic_socket.io_control.overload2 io_control]``(
- IoControlCommand & command,
+ typename ``[link boost_asio.reference.MutableBufferSequence MutableBufferSequence]``>
+ std::size_t ``[link boost_asio.reference.basic_seq_packet_socket.receive.overload2 receive]``(
+ const MutableBufferSequence & buffers,
+ socket_base::message_flags in_flags,
+ socket_base::message_flags & out_flags);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.receive.overload2 more...]]``
+
+
+Receive some data on a connected socket.
+
+
+ template<
+ typename ``[link boost_asio.reference.MutableBufferSequence MutableBufferSequence]``>
+ std::size_t ``[link boost_asio.reference.basic_seq_packet_socket.receive.overload3 receive]``(
+ const MutableBufferSequence & buffers,
+ socket_base::message_flags in_flags,
+ socket_base::message_flags & out_flags,
       boost::system::error_code & ec);
- `` [''''&raquo;''' [link boost_asio.reference.basic_socket.io_control.overload2 more...]]``
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.receive.overload3 more...]]``
 
 
-[section:overload1 basic_socket::io_control (1 of 2 overloads)]
+[section:overload1 basic_seq_packet_socket::receive (1 of 3 overloads)]
 
 
-Perform an IO control command on the socket.
+Receive some data on the socket.
 
 
   template<
- typename ``[link boost_asio.reference.IoControlCommand IoControlCommand]``>
- void io_control(
- IoControlCommand & command);
+ typename ``[link boost_asio.reference.MutableBufferSequence MutableBufferSequence]``>
+ std::size_t receive(
+ const MutableBufferSequence & buffers,
+ socket_base::message_flags & out_flags);
 
 
-This function is used to execute an IO control command on the socket.
+This function is used to receive data on the sequenced packet socket. The function call will block until data has been received successfully, or until an error occurs.
 
 
 [heading Parameters]
@@ -17024,34 +19028,36 @@
 
 [variablelist
   
-[[command][The IO control command to be performed on the socket.]]
+[[buffers][One or more buffers into which the data will be received.]]
+
+[[out_flags][After the receive call completes, contains flags associated with the received data. For example, if the `socket_base::message_end_of_record` bit is set then the received data marks the end of a record.]]
 
 ]
 
 
+[heading Return Value]
+
+The number of bytes received.
+
+
 [heading Exceptions]
     
 
 [variablelist
   
-[[boost::system::system_error][Thrown on failure.]]
+[[boost::system::system_error][Thrown on failure. An error code of `boost::asio::error::eof` indicates that the connection was closed by the peer.]]
 
 ]
 
 
-
 [heading Example]
   
-Getting the number of bytes ready to read:
-
- boost::asio::ip::tcp::socket socket(io_service);
- ...
- boost::asio::ip::tcp::socket::bytes_readable command;
- socket.io_control(command);
- std::size_t bytes_readable = command.get();
+To receive into a single data buffer use the [link boost_asio.reference.buffer `buffer`] function as follows:
 
+ socket.receive(boost::asio::buffer(data, size), out_flags);
 
 
+See the [link boost_asio.reference.buffer `buffer`] documentation for information on receiving into multiple buffers in one go, and how to use it with arrays, boost::array or std::vector.
 
 
 
@@ -17060,20 +19066,21 @@
 
 
 
-[section:overload2 basic_socket::io_control (2 of 2 overloads)]
+[section:overload2 basic_seq_packet_socket::receive (2 of 3 overloads)]
 
 
-Perform an IO control command on the socket.
+Receive some data on the socket.
 
 
   template<
- typename ``[link boost_asio.reference.IoControlCommand IoControlCommand]``>
- boost::system::error_code io_control(
- IoControlCommand & command,
- boost::system::error_code & ec);
+ typename ``[link boost_asio.reference.MutableBufferSequence MutableBufferSequence]``>
+ std::size_t receive(
+ const MutableBufferSequence & buffers,
+ socket_base::message_flags in_flags,
+ socket_base::message_flags & out_flags);
 
 
-This function is used to execute an IO control command on the socket.
+This function is used to receive data on the sequenced packet socket. The function call will block until data has been received successfully, or until an error occurs.
 
 
 [heading Parameters]
@@ -17081,95 +19088,117 @@
 
 [variablelist
   
-[[command][The IO control command to be performed on the socket.]]
+[[buffers][One or more buffers into which the data will be received.]]
 
-[[ec][Set to indicate what error occurred, if any.]]
+[[in_flags][Flags specifying how the receive call is to be made.]]
+
+[[out_flags][After the receive call completes, contains flags associated with the received data. For example, if the `socket_base::message_end_of_record` bit is set then the received data marks the end of a record.]]
 
 ]
 
 
+[heading Return Value]
+
+The number of bytes received.
+
 
-[heading Example]
+[heading Exceptions]
+
+
+[variablelist
   
-Getting the number of bytes ready to read:
+[[boost::system::system_error][Thrown on failure. An error code of `boost::asio::error::eof` indicates that the connection was closed by the peer.]]
 
- boost::asio::ip::tcp::socket socket(io_service);
- ...
- boost::asio::ip::tcp::socket::bytes_readable command;
- boost::system::error_code ec;
- socket.io_control(command, ec);
- if (ec)
- {
- // An error occurred.
- }
- std::size_t bytes_readable = command.get();
+]
 
 
+[heading Remarks]
+
+The receive operation may not receive all of the requested number of bytes. Consider using the [link boost_asio.reference.read `read`] function if you need to ensure that the requested amount of data is read before the blocking operation completes.
 
 
+[heading Example]
+
+To receive into a single data buffer use the [link boost_asio.reference.buffer `buffer`] function as follows:
 
+ socket.receive(boost::asio::buffer(data, size), 0, out_flags);
+
+
+See the [link boost_asio.reference.buffer `buffer`] documentation for information on receiving into multiple buffers in one go, and how to use it with arrays, boost::array or std::vector.
 
 
-[endsect]
 
 
 [endsect]
 
 
-[section:io_service basic_socket::io_service]
 
+[section:overload3 basic_seq_packet_socket::receive (3 of 3 overloads)]
 
-['Inherited from basic_io_object.]
 
-[indexterm2 io_service..basic_socket]
-(Deprecated: use `get_io_service()`.) Get the [link boost_asio.reference.io_service `io_service`] associated with the object.
+Receive some data on a connected socket.
 
 
- boost::asio::io_service & io_service();
+ template<
+ typename ``[link boost_asio.reference.MutableBufferSequence MutableBufferSequence]``>
+ std::size_t receive(
+ const MutableBufferSequence & buffers,
+ socket_base::message_flags in_flags,
+ socket_base::message_flags & out_flags,
+ boost::system::error_code & ec);
 
 
-This function may be used to obtain the [link boost_asio.reference.io_service `io_service`] object that the I/O object uses to dispatch handlers for asynchronous operations.
+This function is used to receive data on the sequenced packet socket. The function call will block until data has been received successfully, or until an error occurs.
 
 
-[heading Return Value]
-
-A reference to the [link boost_asio.reference.io_service `io_service`] object that the I/O object will use to dispatch handlers. Ownership is not transferred to the caller.
+[heading Parameters]
+
 
+[variablelist
+
+[[buffers][One or more buffers into which the data will be received.]]
 
+[[in_flags][Flags specifying how the receive call is to be made.]]
 
+[[out_flags][After the receive call completes, contains flags associated with the received data. For example, if the `socket_base::message_end_of_record` bit is set then the received data marks the end of a record.]]
 
-[endsect]
+[[ec][Set to indicate what error occurred, if any.]]
 
+]
 
 
-[section:is_open basic_socket::is_open]
+[heading Return Value]
+
+The number of bytes received. Returns 0 if an error occurred.
 
-[indexterm2 is_open..basic_socket]
-Determine whether the socket is open.
 
+[heading Remarks]
+
+The receive operation may not receive all of the requested number of bytes. Consider using the [link boost_asio.reference.read `read`] function if you need to ensure that the requested amount of data is read before the blocking operation completes.
 
- bool is_open() const;
 
 
 
 [endsect]
 
 
+[endsect]
 
-[section:keep_alive basic_socket::keep_alive]
+
+[section:receive_buffer_size basic_seq_packet_socket::receive_buffer_size]
 
 
 ['Inherited from socket_base.]
 
-[indexterm2 keep_alive..basic_socket]
-Socket option to send keep-alives.
+[indexterm2 receive_buffer_size..basic_seq_packet_socket]
+Socket option for the receive buffer size of a socket.
 
 
- typedef implementation_defined keep_alive;
+ typedef implementation_defined receive_buffer_size;
 
 
 
-Implements the SOL\_SOCKET/SO\_KEEPALIVE socket option.
+Implements the SOL\_SOCKET/SO\_RCVBUF socket option.
 
 
 [heading Examples]
@@ -17178,7 +19207,7 @@
 
    boost::asio::ip::tcp::socket socket(io_service);
    ...
- boost::asio::socket_base::keep_alive option(true);
+ boost::asio::socket_base::receive_buffer_size option(8192);
    socket.set_option(option);
 
 
@@ -17189,9 +19218,9 @@
 
    boost::asio::ip::tcp::socket socket(io_service);
    ...
- boost::asio::socket_base::keep_alive option;
+ boost::asio::socket_base::receive_buffer_size option;
    socket.get_option(option);
- bool is_set = option.value();
+ int size = option.value();
 
 
 
@@ -17201,7 +19230,7 @@
 
 [heading Requirements]
 
-[*Header: ][^boost/asio/basic_socket.hpp]
+[*Header: ][^boost/asio/basic_seq_packet_socket.hpp]
 
 [*Convenience header: ][^boost/asio.hpp]
 
@@ -17210,20 +19239,20 @@
 
 
 
-[section:linger basic_socket::linger]
+[section:receive_low_watermark basic_seq_packet_socket::receive_low_watermark]
 
 
 ['Inherited from socket_base.]
 
-[indexterm2 linger..basic_socket]
-Socket option to specify whether the socket lingers on close if unsent data is present.
+[indexterm2 receive_low_watermark..basic_seq_packet_socket]
+Socket option for the receive low watermark.
 
 
- typedef implementation_defined linger;
+ typedef implementation_defined receive_low_watermark;
 
 
 
-Implements the SOL\_SOCKET/SO\_LINGER socket option.
+Implements the SOL\_SOCKET/SO\_RCVLOWAT socket option.
 
 
 [heading Examples]
@@ -17232,7 +19261,7 @@
 
    boost::asio::ip::tcp::socket socket(io_service);
    ...
- boost::asio::socket_base::linger option(true, 30);
+ boost::asio::socket_base::receive_low_watermark option(1024);
    socket.set_option(option);
 
 
@@ -17243,10 +19272,9 @@
 
    boost::asio::ip::tcp::socket socket(io_service);
    ...
- boost::asio::socket_base::linger option;
+ boost::asio::socket_base::receive_low_watermark option;
    socket.get_option(option);
- bool is_set = option.enabled();
- unsigned short timeout = option.timeout();
+ int size = option.value();
 
 
 
@@ -17256,7 +19284,7 @@
 
 [heading Requirements]
 
-[*Header: ][^boost/asio/basic_socket.hpp]
+[*Header: ][^boost/asio/basic_seq_packet_socket.hpp]
 
 [*Convenience header: ][^boost/asio.hpp]
 
@@ -17264,35 +19292,38 @@
 [endsect]
 
 
-[section:local_endpoint basic_socket::local_endpoint]
+[section:remote_endpoint basic_seq_packet_socket::remote_endpoint]
 
-[indexterm2 local_endpoint..basic_socket]
-Get the local endpoint of the socket.
+[indexterm2 remote_endpoint..basic_seq_packet_socket]
+Get the remote endpoint of the socket.
 
 
- endpoint_type ``[link boost_asio.reference.basic_socket.local_endpoint.overload1 local_endpoint]``() const;
- `` [''''&raquo;''' [link boost_asio.reference.basic_socket.local_endpoint.overload1 more...]]``
+ endpoint_type ``[link boost_asio.reference.basic_seq_packet_socket.remote_endpoint.overload1 remote_endpoint]``() const;
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.remote_endpoint.overload1 more...]]``
 
- endpoint_type ``[link boost_asio.reference.basic_socket.local_endpoint.overload2 local_endpoint]``(
+ endpoint_type ``[link boost_asio.reference.basic_seq_packet_socket.remote_endpoint.overload2 remote_endpoint]``(
       boost::system::error_code & ec) const;
- `` [''''&raquo;''' [link boost_asio.reference.basic_socket.local_endpoint.overload2 more...]]``
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.remote_endpoint.overload2 more...]]``
 
 
-[section:overload1 basic_socket::local_endpoint (1 of 2 overloads)]
+[section:overload1 basic_seq_packet_socket::remote_endpoint (1 of 2 overloads)]
 
 
-Get the local endpoint of the socket.
+['Inherited from basic_socket.]
 
 
- endpoint_type local_endpoint() const;
+Get the remote endpoint of the socket.
 
 
-This function is used to obtain the locally bound endpoint of the socket.
+ endpoint_type remote_endpoint() const;
+
+
+This function is used to obtain the remote endpoint of the socket.
 
 
 [heading Return Value]
       
-An object that represents the local endpoint of the socket.
+An object that represents the remote endpoint of the socket.
 
 
 [heading Exceptions]
@@ -17311,7 +19342,7 @@
 
    boost::asio::ip::tcp::socket socket(io_service);
    ...
- boost::asio::ip::tcp::endpoint endpoint = socket.local_endpoint();
+ boost::asio::ip::tcp::endpoint endpoint = socket.remote_endpoint();
 
 
 
@@ -17323,17 +19354,20 @@
 
 
 
-[section:overload2 basic_socket::local_endpoint (2 of 2 overloads)]
+[section:overload2 basic_seq_packet_socket::remote_endpoint (2 of 2 overloads)]
 
 
-Get the local endpoint of the socket.
+['Inherited from basic_socket.]
 
 
- endpoint_type local_endpoint(
+Get the remote endpoint of the socket.
+
+
+ endpoint_type remote_endpoint(
       boost::system::error_code & ec) const;
 
 
-This function is used to obtain the locally bound endpoint of the socket.
+This function is used to obtain the remote endpoint of the socket.
 
 
 [heading Parameters]
@@ -17348,7 +19382,7 @@
 
 [heading Return Value]
       
-An object that represents the local endpoint of the socket. Returns a default-constructed endpoint object if an error occurred.
+An object that represents the remote endpoint of the socket. Returns a default-constructed endpoint object if an error occurred.
 
 
 [heading Example]
@@ -17358,7 +19392,7 @@
    boost::asio::ip::tcp::socket socket(io_service);
    ...
    boost::system::error_code ec;
- boost::asio::ip::tcp::endpoint endpoint = socket.local_endpoint(ec);
+ boost::asio::ip::tcp::endpoint endpoint = socket.remote_endpoint(ec);
    if (ec)
    {
      // An error occurred.
@@ -17375,420 +19409,236 @@
 
 [endsect]
 
-[section:lowest_layer basic_socket::lowest_layer]
 
-[indexterm2 lowest_layer..basic_socket]
-Get a reference to the lowest layer.
+[section:reuse_address basic_seq_packet_socket::reuse_address]
 
 
- lowest_layer_type & ``[link boost_asio.reference.basic_socket.lowest_layer.overload1 lowest_layer]``();
- `` [''''&raquo;''' [link boost_asio.reference.basic_socket.lowest_layer.overload1 more...]]``
-
+['Inherited from socket_base.]
 
-Get a const reference to the lowest layer.
+[indexterm2 reuse_address..basic_seq_packet_socket]
+Socket option to allow the socket to be bound to an address that is already in use.
 
 
- const lowest_layer_type & ``[link boost_asio.reference.basic_socket.lowest_layer.overload2 lowest_layer]``() const;
- `` [''''&raquo;''' [link boost_asio.reference.basic_socket.lowest_layer.overload2 more...]]``
+ typedef implementation_defined reuse_address;
 
 
-[section:overload1 basic_socket::lowest_layer (1 of 2 overloads)]
 
+Implements the SOL\_SOCKET/SO\_REUSEADDR socket option.
 
-Get a reference to the lowest layer.
 
+[heading Examples]
+
+Setting the option:
 
- lowest_layer_type & lowest_layer();
+ boost::asio::ip::tcp::acceptor acceptor(io_service);
+ ...
+ boost::asio::socket_base::reuse_address option(true);
+ acceptor.set_option(option);
 
 
-This function returns a reference to the lowest layer in a stack of layers. Since a [link boost_asio.reference.basic_socket `basic_socket`] cannot contain any further layers, it simply returns a reference to itself.
 
 
-[heading Return Value]
-
-A reference to the lowest layer in the stack of layers. Ownership is not transferred to the caller.
 
+Getting the current option value:
 
+ boost::asio::ip::tcp::acceptor acceptor(io_service);
+ ...
+ boost::asio::socket_base::reuse_address option;
+ acceptor.get_option(option);
+ bool is_set = option.value();
 
 
-[endsect]
 
 
 
-[section:overload2 basic_socket::lowest_layer (2 of 2 overloads)]
 
 
-Get a const reference to the lowest layer.
+[heading Requirements]
 
+[*Header: ][^boost/asio/basic_seq_packet_socket.hpp]
 
- const lowest_layer_type & lowest_layer() const;
+[*Convenience header: ][^boost/asio.hpp]
 
 
-This function returns a const reference to the lowest layer in a stack of layers. Since a [link boost_asio.reference.basic_socket `basic_socket`] cannot contain any further layers, it simply returns a reference to itself.
+[endsect]
 
 
-[heading Return Value]
-
-A const reference to the lowest layer in the stack of layers. Ownership is not transferred to the caller.
+[section:send basic_seq_packet_socket::send]
 
+[indexterm2 send..basic_seq_packet_socket]
+Send some data on the socket.
 
 
+ template<
+ typename ``[link boost_asio.reference.ConstBufferSequence ConstBufferSequence]``>
+ std::size_t ``[link boost_asio.reference.basic_seq_packet_socket.send.overload1 send]``(
+ const ConstBufferSequence & buffers,
+ socket_base::message_flags flags);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.send.overload1 more...]]``
 
-[endsect]
+ template<
+ typename ``[link boost_asio.reference.ConstBufferSequence ConstBufferSequence]``>
+ std::size_t ``[link boost_asio.reference.basic_seq_packet_socket.send.overload2 send]``(
+ const ConstBufferSequence & buffers,
+ socket_base::message_flags flags,
+ boost::system::error_code & ec);
+ `` [''''&raquo;''' [link boost_asio.reference.basic_seq_packet_socket.send.overload2 more...]]``
 
 
-[endsect]
+[section:overload1 basic_seq_packet_socket::send (1 of 2 overloads)]
 
 
-[section:lowest_layer_type basic_socket::lowest_layer_type]
+Send some data on the socket.
 
-[indexterm2 lowest_layer_type..basic_socket]
-A [link boost_asio.reference.basic_socket `basic_socket`] is always the lowest layer.
 
+ template<
+ typename ``[link boost_asio.reference.ConstBufferSequence ConstBufferSequence]``>
+ std::size_t send(
+ const ConstBufferSequence & buffers,
+ socket_base::message_flags flags);
 
- typedef basic_socket< Protocol, SocketService > lowest_layer_type;
 
+This function is used to send data on the sequenced packet socket. The function call will block until the data has been sent successfully, or an until error occurs.
 
-[heading Types]
-[table
- [[Name][Description]]
 
- [
+[heading Parameters]
+
 
- [[link boost_asio.reference.basic_socket.broadcast [*broadcast]]]
- [Socket option to permit sending of broadcast messages. ]
+[variablelist
   
- ]
-
- [
+[[buffers][One or more data buffers to be sent on the socket.]]
 
- [[link boost_asio.reference.basic_socket.bytes_readable [*bytes_readable]]]
- [IO control command to get the amount of data that can be read without blocking. ]
-
- ]
+[[flags][Flags specifying how the send call is to be made.]]
 
- [
+]
 
- [[link boost_asio.reference.basic_socket.debug [*debug]]]
- [Socket option to enable socket-level debugging. ]
-
- ]
 
- [
+[heading Return Value]
+
+The number of bytes sent.
 
- [[link boost_asio.reference.basic_socket.do_not_route [*do_not_route]]]
- [Socket option to prevent routing, use local interfaces only. ]
-
- ]
 
- [
+[heading Exceptions]
+
 
- [[link boost_asio.reference.basic_socket.enable_connection_aborted [*enable_connection_aborted]]]
- [Socket option to report aborted connections on accept. ]
+[variablelist
   
- ]
+[[boost::system::system_error][Thrown on failure.]]
 
- [
+]
 
- [[link boost_asio.reference.basic_socket.endpoint_type [*endpoint_type]]]
- [The endpoint type. ]
+
+[heading Example]
   
- ]
+To send a single data buffer use the [link boost_asio.reference.buffer `buffer`] function as follows:
 
- [
+ socket.send(boost::asio::buffer(data, size), 0);
 
- [[link boost_asio.reference.basic_socket.implementation_type [*implementation_type]]]
- [The underlying implementation type of I/O object. ]
-
- ]
 
- [
+See the [link boost_asio.reference.buffer `buffer`] documentation for information on sending multiple buffers in one go, and how to use it with arrays, boost::array or std::vector.
 
- [[link boost_asio.reference.basic_socket.keep_alive [*keep_alive]]]
- [Socket option to send keep-alives. ]
-
- ]
 
- [
 
- [[l