|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r84363 - in trunk: boost boost/asio boost/asio/detail boost/asio/generic boost/asio/generic/detail boost/asio/generic/detail/impl boost/asio/impl libs/asio/doc libs/asio/test libs/asio/test/generic
From: chris_at_[hidden]
Date: 2013-05-19 00:55:14
Author: chris_kohlhoff
Date: 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
New Revision: 84363
URL: http://svn.boost.org/trac/boost/changeset/84363
Log:
Add generic socket protocols and converting move constructors.
Four new protocol classes have been added:
- asio::generic::datagram_protocol
- asio::generic::raw_protocol
- asio::generic::seq_packet_protocol
- asio::generic::stream_protocol
These classes implement the Protocol type requirements, but allow the
user to specify the address family (e.g. AF_INET) and protocol type
(e.g. IPPROTO_TCP) at runtime.
A new endpoint class template, asio::generic::basic_endpoint, has been
added to support these new protocol classes. This endpoint can hold any
other endpoint type, provided its native representation fits into a
sockaddr_storage object.
When using C++11, it is now possible to perform move construction from a
socket (or acceptor) object to convert to the more generic protocol's
socket (or acceptor) type. If the protocol conversion is valid:
Protocol1 p1 = ...;
Protocol2 p2(p1);
then the corresponding socket conversion is allowed:
Protocol1::socket socket1(io_service);
...
Protocol2::socket socket2(std::move(socket1));
For example, one possible conversion is from a TCP socket to a generic
stream-oriented socket:
asio::ip::tcp::socket socket1(io_service);
...
asio::generic::stream_protocol::socket socket2(std::move(socket1));
The conversion is also available for move-assignment. Note that these
conversions are not limited to the newly added generic protocol classes.
User-defined protocols may take advantage of this feature by similarly
ensuring the conversion from Protocol1 to Protocol2 is valid, as above.
As a convenience, the socket acceptor's accept() and async_accept()
functions have been changed so that they can directly accept into a
different protocol's socket type, provided the protocol conversion is
valid. For example, the following is now possible:
asio::ip::tcp::acceptor acceptor(io_service);
...
asio::generic::stream_protocol::socket socket1(io_service);
acceptor.accept(socket1);
Added:
trunk/boost/asio/generic/
trunk/boost/asio/generic/basic_endpoint.hpp (contents, props changed)
trunk/boost/asio/generic/datagram_protocol.hpp (contents, props changed)
trunk/boost/asio/generic/detail/
trunk/boost/asio/generic/detail/endpoint.hpp (contents, props changed)
trunk/boost/asio/generic/detail/impl/
trunk/boost/asio/generic/detail/impl/endpoint.ipp (contents, props changed)
trunk/boost/asio/generic/raw_protocol.hpp (contents, props changed)
trunk/boost/asio/generic/seq_packet_protocol.hpp (contents, props changed)
trunk/boost/asio/generic/stream_protocol.hpp (contents, props changed)
trunk/libs/asio/test/generic/
trunk/libs/asio/test/generic/basic_endpoint.cpp (contents, props changed)
trunk/libs/asio/test/generic/datagram_protocol.cpp (contents, props changed)
trunk/libs/asio/test/generic/raw_protocol.cpp (contents, props changed)
trunk/libs/asio/test/generic/seq_packet_protocol.cpp (contents, props changed)
trunk/libs/asio/test/generic/stream_protocol.cpp (contents, props changed)
Text files modified:
trunk/boost/asio.hpp | 5 ++
trunk/boost/asio/basic_datagram_socket.hpp | 45 +++++++++++++++++++++++
trunk/boost/asio/basic_raw_socket.hpp | 41 +++++++++++++++++++++
trunk/boost/asio/basic_seq_packet_socket.hpp | 45 +++++++++++++++++++++++
trunk/boost/asio/basic_socket.hpp | 46 +++++++++++++++++++++++
trunk/boost/asio/basic_socket_acceptor.hpp | 77 ++++++++++++++++++++++++++++++++++-----
trunk/boost/asio/basic_stream_socket.hpp | 42 +++++++++++++++++++++
trunk/boost/asio/datagram_socket_service.hpp | 14 +++++++
trunk/boost/asio/detail/config.hpp | 4 +
trunk/boost/asio/detail/reactive_socket_service.hpp | 12 ++++++
trunk/boost/asio/impl/src.hpp | 1
trunk/boost/asio/raw_socket_service.hpp | 14 +++++++
trunk/boost/asio/seq_packet_socket_service.hpp | 14 +++++++
trunk/boost/asio/socket_acceptor_service.hpp | 28 +++++++++++---
trunk/boost/asio/stream_socket_service.hpp | 14 +++++++
trunk/libs/asio/doc/reference.xsl | 15 +++++++
trunk/libs/asio/test/Jamfile | 5 ++
trunk/libs/asio/test/Jamfile.v2 | 10 +++++
18 files changed, 414 insertions(+), 18 deletions(-)
Modified: trunk/boost/asio.hpp
==============================================================================
--- trunk/boost/asio.hpp (original)
+++ trunk/boost/asio.hpp 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -46,6 +46,11 @@
#include <boost/asio/deadline_timer_service.hpp>
#include <boost/asio/deadline_timer.hpp>
#include <boost/asio/error.hpp>
+#include <boost/asio/generic/basic_endpoint.hpp>
+#include <boost/asio/generic/datagram_protocol.hpp>
+#include <boost/asio/generic/raw_protocol.hpp>
+#include <boost/asio/generic/seq_packet_protocol.hpp>
+#include <boost/asio/generic/stream_protocol.hpp>
#include <boost/asio/handler_alloc_hook.hpp>
#include <boost/asio/handler_continuation_hook.hpp>
#include <boost/asio/handler_invoke_hook.hpp>
Modified: trunk/boost/asio/basic_datagram_socket.hpp
==============================================================================
--- trunk/boost/asio/basic_datagram_socket.hpp (original)
+++ trunk/boost/asio/basic_datagram_socket.hpp 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -21,6 +21,7 @@
#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/detail/type_traits.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/detail/push_options.hpp>
@@ -166,6 +167,50 @@
BOOST_ASIO_MOVE_CAST(basic_datagram_socket)(other));
return *this;
}
+
+ /// Move-construct a basic_datagram_socket from a socket of another protocol
+ /// type.
+ /**
+ * This constructor moves a datagram socket from one object to another.
+ *
+ * @param other The other basic_datagram_socket object from which the move
+ * will occur.
+ *
+ * @note Following the move, the moved-from object is in the same state as if
+ * constructed using the @c basic_datagram_socket(io_service&) constructor.
+ */
+ template <typename Protocol1, typename DatagramSocketService1>
+ basic_datagram_socket(
+ basic_datagram_socket<Protocol1, DatagramSocketService1>&& other,
+ typename enable_if<is_convertible<Protocol1, Protocol>::value>::type* = 0)
+ : basic_socket<Protocol, DatagramSocketService>(
+ BOOST_ASIO_MOVE_CAST2(basic_datagram_socket<
+ Protocol1, DatagramSocketService1>)(other))
+ {
+ }
+
+ /// Move-assign a basic_datagram_socket from a socket of another protocol
+ /// type.
+ /**
+ * This assignment operator moves a datagram socket from one object to
+ * another.
+ *
+ * @param other The other basic_datagram_socket object from which the move
+ * will occur.
+ *
+ * @note Following the move, the moved-from object is in the same state as if
+ * constructed using the @c basic_datagram_socket(io_service&) constructor.
+ */
+ template <typename Protocol1, typename DatagramSocketService1>
+ typename enable_if<is_convertible<Protocol1, Protocol>::value,
+ basic_datagram_socket>::type& operator=(
+ basic_datagram_socket<Protocol1, DatagramSocketService1>&& other)
+ {
+ basic_socket<Protocol, DatagramSocketService>::operator=(
+ BOOST_ASIO_MOVE_CAST2(basic_datagram_socket<
+ Protocol1, DatagramSocketService1>)(other));
+ return *this;
+ }
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Send some data on a connected socket.
Modified: trunk/boost/asio/basic_raw_socket.hpp
==============================================================================
--- trunk/boost/asio/basic_raw_socket.hpp (original)
+++ trunk/boost/asio/basic_raw_socket.hpp 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -20,6 +20,7 @@
#include <boost/asio/basic_socket.hpp>
#include <boost/asio/detail/handler_type_requirements.hpp>
#include <boost/asio/detail/throw_error.hpp>
+#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/raw_socket_service.hpp>
@@ -165,6 +166,46 @@
BOOST_ASIO_MOVE_CAST(basic_raw_socket)(other));
return *this;
}
+
+ /// Move-construct a basic_raw_socket from a socket of another protocol type.
+ /**
+ * This constructor moves a raw socket from one object to another.
+ *
+ * @param other The other basic_raw_socket object from which the move will
+ * occur.
+ *
+ * @note Following the move, the moved-from object is in the same state as if
+ * constructed using the @c basic_raw_socket(io_service&) constructor.
+ */
+ template <typename Protocol1, typename RawSocketService1>
+ basic_raw_socket(basic_raw_socket<Protocol1, RawSocketService1>&& other,
+ typename enable_if<is_convertible<Protocol1, Protocol>::value>::type* = 0)
+ : basic_socket<Protocol, RawSocketService>(
+ BOOST_ASIO_MOVE_CAST2(basic_raw_socket<
+ Protocol1, RawSocketService1>)(other))
+ {
+ }
+
+ /// Move-assign a basic_raw_socket from a socket of another protocol type.
+ /**
+ * This assignment operator moves a raw socket from one object to another.
+ *
+ * @param other The other basic_raw_socket object from which the move
+ * will occur.
+ *
+ * @note Following the move, the moved-from object is in the same state as if
+ * constructed using the @c basic_raw_socket(io_service&) constructor.
+ */
+ template <typename Protocol1, typename RawSocketService1>
+ typename enable_if<is_convertible<Protocol1, Protocol>::value,
+ basic_raw_socket>::type& operator=(
+ basic_raw_socket<Protocol1, RawSocketService1>&& other)
+ {
+ basic_socket<Protocol, RawSocketService>::operator=(
+ BOOST_ASIO_MOVE_CAST2(basic_raw_socket<
+ Protocol1, RawSocketService1>)(other));
+ return *this;
+ }
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Send some data on a connected socket.
Modified: trunk/boost/asio/basic_seq_packet_socket.hpp
==============================================================================
--- trunk/boost/asio/basic_seq_packet_socket.hpp (original)
+++ trunk/boost/asio/basic_seq_packet_socket.hpp 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -171,6 +171,51 @@
BOOST_ASIO_MOVE_CAST(basic_seq_packet_socket)(other));
return *this;
}
+
+ /// Move-construct a basic_seq_packet_socket from a socket of another protocol
+ /// type.
+ /**
+ * This constructor moves a sequenced packet socket from one object to
+ * another.
+ *
+ * @param other The other basic_seq_packet_socket object from which the move
+ * will occur.
+ *
+ * @note Following the move, the moved-from object is in the same state as if
+ * constructed using the @c basic_seq_packet_socket(io_service&) constructor.
+ */
+ template <typename Protocol1, typename SeqPacketSocketService1>
+ basic_seq_packet_socket(
+ basic_seq_packet_socket<Protocol1, SeqPacketSocketService1>&& other,
+ typename enable_if<is_convertible<Protocol1, Protocol>::value>::type* = 0)
+ : basic_socket<Protocol, SeqPacketSocketService>(
+ BOOST_ASIO_MOVE_CAST2(basic_seq_packet_socket<
+ Protocol1, SeqPacketSocketService1>)(other))
+ {
+ }
+
+ /// Move-assign a basic_seq_packet_socket from a socket of another protocol
+ /// type.
+ /**
+ * This assignment operator moves a sequenced packet socket from one object to
+ * another.
+ *
+ * @param other The other basic_seq_packet_socket object from which the move
+ * will occur.
+ *
+ * @note Following the move, the moved-from object is in the same state as if
+ * constructed using the @c basic_seq_packet_socket(io_service&) constructor.
+ */
+ template <typename Protocol1, typename SeqPacketSocketService1>
+ typename enable_if<is_convertible<Protocol1, Protocol>::value,
+ basic_seq_packet_socket>::type& operator=(
+ basic_seq_packet_socket<Protocol1, SeqPacketSocketService1>&& other)
+ {
+ basic_socket<Protocol, SeqPacketSocketService>::operator=(
+ BOOST_ASIO_MOVE_CAST2(basic_seq_packet_socket<
+ Protocol1, SeqPacketSocketService1>)(other));
+ return *this;
+ }
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Send some data on the socket.
Modified: trunk/boost/asio/basic_socket.hpp
==============================================================================
--- trunk/boost/asio/basic_socket.hpp (original)
+++ trunk/boost/asio/basic_socket.hpp 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -20,6 +20,7 @@
#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/detail/type_traits.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/socket_base.hpp>
@@ -174,6 +175,51 @@
BOOST_ASIO_MOVE_CAST(basic_socket)(other));
return *this;
}
+
+ // All sockets have access to each other's implementations.
+ template <typename Protocol1, typename SocketService1>
+ friend class basic_socket;
+
+ /// Move-construct a basic_socket from a socket of another protocol type.
+ /**
+ * This constructor moves a socket from one object to another.
+ *
+ * @param other The other basic_socket object from which the move will
+ * occur.
+ *
+ * @note Following the move, the moved-from object is in the same state as if
+ * constructed using the @c basic_socket(io_service&) constructor.
+ */
+ template <typename Protocol1, typename SocketService1>
+ basic_socket(basic_socket<Protocol1, SocketService1>&& other,
+ typename enable_if<is_convertible<Protocol1, Protocol>::value>::type* = 0)
+ : basic_io_object<SocketService>(other.get_io_service())
+ {
+ this->get_service().template converting_move_construct<Protocol1>(
+ this->get_implementation(), other.get_implementation());
+ }
+
+ /// Move-assign a basic_socket from a socket of another protocol type.
+ /**
+ * This assignment operator moves a socket from one object to another.
+ *
+ * @param other The other basic_socket object from which the move will
+ * occur.
+ *
+ * @note Following the move, the moved-from object is in the same state as if
+ * constructed using the @c basic_socket(io_service&) constructor.
+ */
+ template <typename Protocol1, typename SocketService1>
+ typename enable_if<is_convertible<Protocol1, Protocol>::value,
+ basic_socket>::type& operator=(
+ basic_socket<Protocol1, SocketService1>&& other)
+ {
+ basic_socket tmp(BOOST_ASIO_MOVE_CAST2(basic_socket<
+ Protocol1, SocketService1>)(other));
+ basic_io_object<SocketService>::operator=(
+ BOOST_ASIO_MOVE_CAST(basic_socket)(tmp));
+ return *this;
+ }
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Get a reference to the lowest layer.
Modified: trunk/boost/asio/basic_socket_acceptor.hpp
==============================================================================
--- trunk/boost/asio/basic_socket_acceptor.hpp (original)
+++ trunk/boost/asio/basic_socket_acceptor.hpp 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -20,6 +20,7 @@
#include <boost/asio/basic_socket.hpp>
#include <boost/asio/detail/handler_type_requirements.hpp>
#include <boost/asio/detail/throw_error.hpp>
+#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/socket_acceptor_service.hpp>
#include <boost/asio/socket_base.hpp>
@@ -211,6 +212,54 @@
BOOST_ASIO_MOVE_CAST(basic_socket_acceptor)(other));
return *this;
}
+
+ // All socket acceptors have access to each other's implementations.
+ template <typename Protocol1, typename SocketAcceptorService1>
+ friend class basic_socket_acceptor;
+
+ /// Move-construct a basic_socket_acceptor from an acceptor of another
+ /// protocol type.
+ /**
+ * This constructor moves an acceptor from one object to another.
+ *
+ * @param other The other basic_socket_acceptor object from which the move
+ * will occur.
+ *
+ * @note Following the move, the moved-from object is in the same state as if
+ * constructed using the @c basic_socket(io_service&) constructor.
+ */
+ template <typename Protocol1, typename SocketAcceptorService1>
+ basic_socket_acceptor(
+ basic_socket_acceptor<Protocol1, SocketAcceptorService1>&& other,
+ typename enable_if<is_convertible<Protocol1, Protocol>::value>::type* = 0)
+ : basic_io_object<SocketAcceptorService>(other.get_io_service())
+ {
+ this->get_service().template converting_move_construct<Protocol1>(
+ this->get_implementation(), other.get_implementation());
+ }
+
+ /// Move-assign a basic_socket_acceptor from an acceptor of another protocol
+ /// type.
+ /**
+ * This assignment operator moves an acceptor from one object to another.
+ *
+ * @param other The other basic_socket_acceptor object from which the move
+ * will occur.
+ *
+ * @note Following the move, the moved-from object is in the same state as if
+ * constructed using the @c basic_socket(io_service&) constructor.
+ */
+ template <typename Protocol1, typename SocketAcceptorService1>
+ typename enable_if<is_convertible<Protocol1, Protocol>::value,
+ basic_socket_acceptor>::type& operator=(
+ basic_socket_acceptor<Protocol1, SocketAcceptorService1>&& other)
+ {
+ basic_socket_acceptor tmp(BOOST_ASIO_MOVE_CAST2(basic_socket_acceptor<
+ Protocol1, SocketAcceptorService1>)(other));
+ basic_io_object<SocketAcceptorService>::operator=(
+ BOOST_ASIO_MOVE_CAST(basic_socket_acceptor)(tmp));
+ return *this;
+ }
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Open the acceptor using the specified protocol.
@@ -871,11 +920,13 @@
* acceptor.accept(socket);
* @endcode
*/
- template <typename SocketService>
- void accept(basic_socket<protocol_type, SocketService>& peer)
+ template <typename Protocol1, typename SocketService>
+ void accept(basic_socket<Protocol1, SocketService>& peer,
+ typename enable_if<is_convertible<Protocol, Protocol1>::value>::type* = 0)
{
boost::system::error_code ec;
- this->get_service().accept(this->get_implementation(), peer, 0, ec);
+ this->get_service().accept(this->get_implementation(),
+ peer, static_cast<endpoint_type*>(0), ec);
boost::asio::detail::throw_error(ec, "accept");
}
@@ -902,12 +953,14 @@
* }
* @endcode
*/
- template <typename SocketService>
+ template <typename Protocol1, typename SocketService>
boost::system::error_code accept(
- basic_socket<protocol_type, SocketService>& peer,
- boost::system::error_code& ec)
+ basic_socket<Protocol1, SocketService>& peer,
+ boost::system::error_code& ec,
+ typename enable_if<is_convertible<Protocol, Protocol1>::value>::type* = 0)
{
- return this->get_service().accept(this->get_implementation(), peer, 0, ec);
+ return this->get_service().accept(this->get_implementation(),
+ peer, static_cast<endpoint_type*>(0), ec);
}
/// Start an asynchronous accept.
@@ -948,18 +1001,20 @@
* acceptor.async_accept(socket, accept_handler);
* @endcode
*/
- template <typename SocketService, typename AcceptHandler>
+ template <typename Protocol1, typename SocketService, typename AcceptHandler>
BOOST_ASIO_INITFN_RESULT_TYPE(AcceptHandler,
void (boost::system::error_code))
- async_accept(basic_socket<protocol_type, SocketService>& peer,
- BOOST_ASIO_MOVE_ARG(AcceptHandler) handler)
+ async_accept(basic_socket<Protocol1, SocketService>& peer,
+ BOOST_ASIO_MOVE_ARG(AcceptHandler) handler,
+ typename enable_if<is_convertible<Protocol, Protocol1>::value>::type* = 0)
{
// 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;
return this->get_service().async_accept(this->get_implementation(),
- peer, 0, BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler));
+ peer, static_cast<endpoint_type*>(0),
+ BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler));
}
/// Accept a new connection and obtain the endpoint of the peer
Modified: trunk/boost/asio/basic_stream_socket.hpp
==============================================================================
--- trunk/boost/asio/basic_stream_socket.hpp (original)
+++ trunk/boost/asio/basic_stream_socket.hpp 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -167,6 +167,48 @@
BOOST_ASIO_MOVE_CAST(basic_stream_socket)(other));
return *this;
}
+
+ /// Move-construct a basic_stream_socket from a socket of another protocol
+ /// type.
+ /**
+ * This constructor moves a stream socket from one object to another.
+ *
+ * @param other The other basic_stream_socket object from which the move
+ * will occur.
+ *
+ * @note Following the move, the moved-from object is in the same state as if
+ * constructed using the @c basic_stream_socket(io_service&) constructor.
+ */
+ template <typename Protocol1, typename StreamSocketService1>
+ basic_stream_socket(
+ basic_stream_socket<Protocol1, StreamSocketService1>&& other,
+ typename enable_if<is_convertible<Protocol1, Protocol>::value>::type* = 0)
+ : basic_socket<Protocol, StreamSocketService>(
+ BOOST_ASIO_MOVE_CAST2(basic_stream_socket<
+ Protocol1, StreamSocketService1>)(other))
+ {
+ }
+
+ /// Move-assign a basic_stream_socket from a socket of another protocol type.
+ /**
+ * This assignment operator moves a stream socket from one object to another.
+ *
+ * @param other The other basic_stream_socket object from which the move
+ * will occur.
+ *
+ * @note Following the move, the moved-from object is in the same state as if
+ * constructed using the @c basic_stream_socket(io_service&) constructor.
+ */
+ template <typename Protocol1, typename StreamSocketService1>
+ typename enable_if<is_convertible<Protocol1, Protocol>::value,
+ basic_stream_socket>::type& operator=(
+ basic_stream_socket<Protocol1, StreamSocketService1>&& other)
+ {
+ basic_socket<Protocol, StreamSocketService>::operator=(
+ BOOST_ASIO_MOVE_CAST2(basic_stream_socket<
+ Protocol1, StreamSocketService1>)(other));
+ return *this;
+ }
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Send some data on the socket.
Modified: trunk/boost/asio/datagram_socket_service.hpp
==============================================================================
--- trunk/boost/asio/datagram_socket_service.hpp (original)
+++ trunk/boost/asio/datagram_socket_service.hpp 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -18,6 +18,7 @@
#include <boost/asio/detail/config.hpp>
#include <cstddef>
#include <boost/asio/async_result.hpp>
+#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/io_service.hpp>
@@ -112,6 +113,19 @@
{
service_impl_.move_assign(impl, other_service.service_impl_, other_impl);
}
+
+ /// Move-construct a new datagram socket implementation from another protocol
+ /// type.
+ template <typename Protocol1>
+ void converting_move_construct(implementation_type& impl,
+ typename datagram_socket_service<
+ Protocol1>::implementation_type& other_impl,
+ typename enable_if<is_convertible<
+ Protocol1, Protocol>::value>::type* = 0)
+ {
+ service_impl_.template converting_move_construct<Protocol1>(
+ impl, other_impl);
+ }
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Destroy a datagram socket implementation.
Modified: trunk/boost/asio/detail/config.hpp
==============================================================================
--- trunk/boost/asio/detail/config.hpp (original)
+++ trunk/boost/asio/detail/config.hpp 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -106,6 +106,7 @@
#if defined(BOOST_ASIO_HAS_MOVE) && !defined(BOOST_ASIO_MOVE_CAST)
# define BOOST_ASIO_MOVE_ARG(type) type&&
# define BOOST_ASIO_MOVE_CAST(type) static_cast<type&&>
+# define BOOST_ASIO_MOVE_CAST2(type1, type2) static_cast<type1, type2&&>
#endif // defined(BOOST_ASIO_HAS_MOVE) && !defined(BOOST_ASIO_MOVE_CAST)
// If BOOST_ASIO_MOVE_CAST still isn't defined, default to a C++03-compatible
@@ -130,7 +131,8 @@
# define BOOST_ASIO_MOVE_ARG(type) type
# endif
# define BOOST_ASIO_MOVE_CAST(type) static_cast<const type&>
-#endif // !defined_BOOST_ASIO_MOVE_CAST
+# define BOOST_ASIO_MOVE_CAST2(type1, type2) static_cast<const type1, type2&>
+#endif // !defined(BOOST_ASIO_MOVE_CAST)
// Support variadic templates on compilers known to allow it.
#if !defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
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 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -99,6 +99,18 @@
other_impl.protocol_ = endpoint_type().protocol();
}
+ // Move-construct a new socket implementation from another protocol type.
+ template <typename Protocol1>
+ void converting_move_construct(implementation_type& impl,
+ typename reactive_socket_service<
+ Protocol1>::implementation_type& other_impl)
+ {
+ this->base_move_construct(impl, other_impl);
+
+ impl.protocol_ = protocol_type(other_impl.protocol_);
+ other_impl.protocol_ = typename Protocol1::endpoint().protocol();
+ }
+
// Open a new socket implementation.
boost::system::error_code open(implementation_type& impl,
const protocol_type& protocol, boost::system::error_code& ec)
Added: trunk/boost/asio/generic/basic_endpoint.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/asio/generic/basic_endpoint.hpp 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -0,0 +1,195 @@
+//
+// generic/basic_endpoint.hpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2013 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_GENERIC_BASIC_ENDPOINT_HPP
+#define BOOST_ASIO_GENERIC_BASIC_ENDPOINT_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/generic/detail/endpoint.hpp>
+
+#include <boost/asio/detail/push_options.hpp>
+
+namespace boost {
+namespace asio {
+namespace generic {
+
+/// Describes an endpoint for any socket type.
+/**
+ * The boost::asio::generic::basic_endpoint class template describes an endpoint
+ * that may be associated with any socket type.
+ *
+ * @note The socket types sockaddr type must be able to fit into a
+ * @c sockaddr_storage structure.
+ *
+ * @par Thread Safety
+ * @e Distinct @e objects: Safe._at_n
+ * @e Shared @e objects: Unsafe.
+ *
+ * @par Concepts:
+ * Endpoint.
+ */
+template <typename Protocol>
+class basic_endpoint
+{
+public:
+ /// The protocol type associated with the endpoint.
+ typedef Protocol protocol_type;
+
+ /// The type of the endpoint structure. This type is dependent on the
+ /// underlying implementation of the socket layer.
+#if defined(GENERATING_DOCUMENTATION)
+ typedef implementation_defined data_type;
+#else
+ typedef boost::asio::detail::socket_addr_type data_type;
+#endif
+
+ /// Default constructor.
+ basic_endpoint()
+ {
+ }
+
+ /// Construct an endpoint from the specified socket address.
+ basic_endpoint(const void* socket_address,
+ std::size_t socket_address_size, int socket_protocol = 0)
+ : impl_(socket_address, socket_address_size, socket_protocol)
+ {
+ }
+
+ /// Construct an endpoint from the specific endpoint type.
+ template <typename Endpoint>
+ basic_endpoint(const Endpoint& endpoint)
+ : impl_(endpoint.data(), endpoint.size(), endpoint.protocol().protocol())
+ {
+ }
+
+ /// Copy constructor.
+ basic_endpoint(const basic_endpoint& other)
+ : impl_(other.impl_)
+ {
+ }
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ /// Move constructor.
+ basic_endpoint(basic_endpoint&& other)
+ : impl_(other.impl_)
+ {
+ }
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ /// Assign from another endpoint.
+ basic_endpoint& operator=(const basic_endpoint& other)
+ {
+ impl_ = other.impl_;
+ return *this;
+ }
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ /// Move-assign from another endpoint.
+ basic_endpoint& operator=(basic_endpoint&& other)
+ {
+ impl_ = other.impl_;
+ return *this;
+ }
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ /// The protocol associated with the endpoint.
+ protocol_type protocol() const
+ {
+ return protocol_type(impl_.family(), impl_.protocol());
+ }
+
+ /// Get the underlying endpoint in the native type.
+ data_type* data()
+ {
+ return impl_.data();
+ }
+
+ /// Get the underlying endpoint in the native type.
+ const data_type* data() const
+ {
+ return impl_.data();
+ }
+
+ /// Get the underlying size of the endpoint in the native type.
+ std::size_t size() const
+ {
+ return impl_.size();
+ }
+
+ /// Set the underlying size of the endpoint in the native type.
+ void resize(std::size_t new_size)
+ {
+ impl_.resize(new_size);
+ }
+
+ /// Get the capacity of the endpoint in the native type.
+ std::size_t capacity() const
+ {
+ return impl_.capacity();
+ }
+
+ /// Compare two endpoints for equality.
+ friend bool operator==(const basic_endpoint<Protocol>& e1,
+ const basic_endpoint<Protocol>& e2)
+ {
+ return e1.impl_ == e2.impl_;
+ }
+
+ /// Compare two endpoints for inequality.
+ friend bool operator!=(const basic_endpoint<Protocol>& e1,
+ const basic_endpoint<Protocol>& e2)
+ {
+ return !(e1.impl_ == e2.impl_);
+ }
+
+ /// Compare endpoints for ordering.
+ friend bool operator<(const basic_endpoint<Protocol>& e1,
+ const basic_endpoint<Protocol>& e2)
+ {
+ return e1.impl_ < e2.impl_;
+ }
+
+ /// Compare endpoints for ordering.
+ friend bool operator>(const basic_endpoint<Protocol>& e1,
+ const basic_endpoint<Protocol>& e2)
+ {
+ return e2.impl_ < e1.impl_;
+ }
+
+ /// Compare endpoints for ordering.
+ friend bool operator<=(const basic_endpoint<Protocol>& e1,
+ const basic_endpoint<Protocol>& e2)
+ {
+ return !(e2 < e1);
+ }
+
+ /// Compare endpoints for ordering.
+ friend bool operator>=(const basic_endpoint<Protocol>& e1,
+ const basic_endpoint<Protocol>& e2)
+ {
+ return !(e1 < e2);
+ }
+
+private:
+ // The underlying generic endpoint.
+ boost::asio::generic::detail::endpoint impl_;
+};
+
+} // namespace generic
+} // namespace asio
+} // namespace boost
+
+#include <boost/asio/detail/pop_options.hpp>
+
+#endif // BOOST_ASIO_GENERIC_BASIC_ENDPOINT_HPP
Added: trunk/boost/asio/generic/datagram_protocol.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/asio/generic/datagram_protocol.hpp 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -0,0 +1,125 @@
+//
+// generic/datagram_protocol.hpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2013 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_GENERIC_DATAGRAM_PROTOCOL_HPP
+#define BOOST_ASIO_GENERIC_DATAGRAM_PROTOCOL_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
+
+#include <boost/asio/detail/config.hpp>
+
+#include <typeinfo>
+#include <boost/asio/basic_datagram_socket.hpp>
+#include <boost/asio/detail/socket_types.hpp>
+#include <boost/asio/detail/throw_exception.hpp>
+#include <boost/asio/generic/basic_endpoint.hpp>
+
+#include <boost/asio/detail/push_options.hpp>
+
+namespace boost {
+namespace asio {
+namespace generic {
+
+/// Encapsulates the flags needed for a generic datagram-oriented socket.
+/**
+ * The boost::asio::generic::datagram_protocol class contains flags necessary
+ * for datagram-oriented sockets of any address family and protocol.
+ *
+ * @par Examples
+ * Constructing using a native address family and socket protocol:
+ * @code datagram_protocol p(AF_INET, IPPROTO_UDP); @endcode
+ * Constructing from a specific protocol type:
+ * @code datagram_protocol p(boost::asio::ip::udp::v4()); @endcode
+ *
+ * @par Thread Safety
+ * @e Distinct @e objects: Safe._at_n
+ * @e Shared @e objects: Safe.
+ *
+ * @par Concepts:
+ * Protocol.
+ */
+class datagram_protocol
+{
+public:
+ /// Construct a protocol object for a specific address family and protocol.
+ datagram_protocol(int address_family, int socket_protocol)
+ : family_(address_family),
+ protocol_(socket_protocol)
+ {
+ }
+
+ /// Construct a generic protocol object from a specific protocol.
+ /**
+ * @throws @c bad_cast Thrown if the source protocol is not datagram-oriented.
+ */
+ template <typename Protocol>
+ datagram_protocol(const Protocol& source_protocol)
+ : family_(source_protocol.family()),
+ protocol_(source_protocol.protocol())
+ {
+ if (source_protocol.type() != type())
+ {
+ std::bad_cast ex;
+ boost::asio::detail::throw_exception(ex);
+ }
+ }
+
+ /// Obtain an identifier for the type of the protocol.
+ int type() const
+ {
+ return SOCK_DGRAM;
+ }
+
+ /// Obtain an identifier for the protocol.
+ int protocol() const
+ {
+ return protocol_;
+ }
+
+ /// Obtain an identifier for the protocol family.
+ int family() const
+ {
+ return family_;
+ }
+
+ /// Compare two protocols for equality.
+ friend bool operator==(const datagram_protocol& p1,
+ const datagram_protocol& p2)
+ {
+ return p1.family_ == p2.family_ && p1.protocol_ == p2.protocol_;
+ }
+
+ /// Compare two protocols for inequality.
+ friend bool operator!=(const datagram_protocol& p1,
+ const datagram_protocol& p2)
+ {
+ return !(p1 == p2);
+ }
+
+ /// The type of an endpoint.
+ typedef basic_endpoint<datagram_protocol> endpoint;
+
+ /// The generic socket type.
+ typedef basic_datagram_socket<datagram_protocol> socket;
+
+private:
+ int family_;
+ int protocol_;
+};
+
+} // namespace generic
+} // namespace asio
+} // namespace boost
+
+#include <boost/asio/detail/pop_options.hpp>
+
+#endif // BOOST_ASIO_GENERIC_DATAGRAM_PROTOCOL_HPP
Added: trunk/boost/asio/generic/detail/endpoint.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/asio/generic/detail/endpoint.hpp 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -0,0 +1,135 @@
+//
+// generic/detail/endpoint.hpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2013 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_GENERIC_DETAIL_ENDPOINT_HPP
+#define BOOST_ASIO_GENERIC_DETAIL_ENDPOINT_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/detail/socket_types.hpp>
+
+#include <boost/asio/detail/push_options.hpp>
+
+namespace boost {
+namespace asio {
+namespace generic {
+namespace detail {
+
+// Helper class for implementing a generic socket endpoint.
+class endpoint
+{
+public:
+ // Default constructor.
+ BOOST_ASIO_DECL endpoint();
+
+ // Construct an endpoint from the specified raw bytes.
+ BOOST_ASIO_DECL endpoint(const void* sock_addr,
+ std::size_t sock_addr_size, int sock_protocol);
+
+ // Copy constructor.
+ endpoint(const endpoint& other)
+ : data_(other.data_),
+ size_(other.size_),
+ protocol_(other.protocol_)
+ {
+ }
+
+ // Assign from another endpoint.
+ endpoint& operator=(const endpoint& other)
+ {
+ data_ = other.data_;
+ size_ = other.size_;
+ protocol_ = other.protocol_;
+ return *this;
+ }
+
+ // Get the address family associated with the endpoint.
+ int family() const
+ {
+ return data_.base.sa_family;
+ }
+
+ // Get the socket protocol associated with the endpoint.
+ int protocol() const
+ {
+ return protocol_;
+ }
+
+ // Get the underlying endpoint in the native type.
+ boost::asio::detail::socket_addr_type* data()
+ {
+ return &data_.base;
+ }
+
+ // Get the underlying endpoint in the native type.
+ const boost::asio::detail::socket_addr_type* data() const
+ {
+ return &data_.base;
+ }
+
+ // Get the underlying size of the endpoint in the native type.
+ std::size_t size() const
+ {
+ return size_;
+ }
+
+ // Set the underlying size of the endpoint in the native type.
+ BOOST_ASIO_DECL void resize(std::size_t size);
+
+ // Get the capacity of the endpoint in the native type.
+ std::size_t capacity() const
+ {
+ return sizeof(boost::asio::detail::sockaddr_storage_type);
+ }
+
+ // Compare two endpoints for equality.
+ BOOST_ASIO_DECL friend bool operator==(
+ const endpoint& e1, const endpoint& e2);
+
+ // Compare endpoints for ordering.
+ BOOST_ASIO_DECL friend bool operator<(
+ const endpoint& e1, const endpoint& e2);
+
+private:
+ // The underlying socket address.
+ union data_union
+ {
+ boost::asio::detail::socket_addr_type base;
+ boost::asio::detail::sockaddr_storage_type generic;
+ } data_;
+
+ // The length of the socket address stored in the endpoint.
+ std::size_t size_;
+
+ // The socket protocol associated with the endpoint.
+ int protocol_;
+
+ // Initialise with a specified memory.
+ BOOST_ASIO_DECL void init(const void* sock_addr,
+ std::size_t sock_addr_size, int sock_protocol);
+};
+
+} // namespace detail
+} // namespace generic
+} // namespace asio
+} // namespace boost
+
+#include <boost/asio/detail/pop_options.hpp>
+
+#if defined(BOOST_ASIO_HEADER_ONLY)
+# include <boost/asio/generic/detail/impl/endpoint.ipp>
+#endif // defined(BOOST_ASIO_HEADER_ONLY)
+
+#endif // BOOST_ASIO_GENERIC_DETAIL_ENDPOINT_HPP
Added: trunk/boost/asio/generic/detail/impl/endpoint.ipp
==============================================================================
--- (empty file)
+++ trunk/boost/asio/generic/detail/impl/endpoint.ipp 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -0,0 +1,111 @@
+//
+// generic/detail/impl/endpoint.hpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2013 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_GENERIC_DETAIL_IMPL_ENDPOINT_IPP
+#define BOOST_ASIO_GENERIC_DETAIL_IMPL_ENDPOINT_IPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
+
+#include <boost/asio/detail/config.hpp>
+
+#include <cstring>
+#include <typeinfo>
+#include <boost/asio/detail/socket_ops.hpp>
+#include <boost/asio/detail/throw_error.hpp>
+#include <boost/asio/detail/throw_exception.hpp>
+#include <boost/asio/error.hpp>
+#include <boost/asio/generic/detail/endpoint.hpp>
+
+#include <boost/asio/detail/push_options.hpp>
+
+namespace boost {
+namespace asio {
+namespace generic {
+namespace detail {
+
+endpoint::endpoint()
+{
+ init(0, 0, 0);
+}
+
+endpoint::endpoint(const void* sock_addr,
+ std::size_t sock_addr_size, int sock_protocol)
+{
+ init(sock_addr, sock_addr_size, sock_protocol);
+}
+
+void endpoint::resize(std::size_t new_size)
+{
+ 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);
+ }
+ else
+ {
+ size_ = new_size;
+ protocol_ = 0;
+ }
+}
+
+bool operator==(const endpoint& e1, const endpoint& e2)
+{
+ using namespace std; // For memcmp.
+ return e1.size() == e2.size() && memcmp(e1.data(), e2.data(), e1.size()) == 0;
+}
+
+bool operator<(const endpoint& e1, const endpoint& e2)
+{
+ if (e1.protocol() < e2.protocol())
+ return true;
+
+ if (e1.protocol() > e2.protocol())
+ return false;
+
+ using namespace std; // For memcmp.
+ std::size_t compare_size = e1.size() < e2.size() ? e1.size() : e2.size();
+ int compare_result = memcmp(e1.data(), e2.data(), compare_size);
+
+ if (compare_result < 0)
+ return true;
+
+ if (compare_result > 0)
+ return false;
+
+ return e1.size() < e2.size();
+}
+
+void endpoint::init(const void* sock_addr,
+ std::size_t sock_addr_size, int sock_protocol)
+{
+ if (sock_addr_size > sizeof(boost::asio::detail::sockaddr_storage_type))
+ {
+ boost::system::error_code ec(boost::asio::error::invalid_argument);
+ boost::asio::detail::throw_error(ec);
+ }
+
+ using namespace std; // For memset and memcpy.
+ memset(&data_.generic, 0, sizeof(boost::asio::detail::sockaddr_storage_type));
+ memcpy(&data_.generic, sock_addr, sock_addr_size);
+
+ size_ = sock_addr_size;
+ protocol_ = sock_protocol;
+}
+
+} // namespace detail
+} // namespace generic
+} // namespace asio
+} // namespace boost
+
+#include <boost/asio/detail/pop_options.hpp>
+
+#endif // BOOST_ASIO_GENERIC_DETAIL_IMPL_ENDPOINT_IPP
Added: trunk/boost/asio/generic/raw_protocol.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/asio/generic/raw_protocol.hpp 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -0,0 +1,123 @@
+//
+// generic/raw_protocol.hpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2013 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_GENERIC_RAW_PROTOCOL_HPP
+#define BOOST_ASIO_GENERIC_RAW_PROTOCOL_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
+
+#include <boost/asio/detail/config.hpp>
+
+#include <typeinfo>
+#include <boost/asio/basic_raw_socket.hpp>
+#include <boost/asio/detail/socket_types.hpp>
+#include <boost/asio/detail/throw_exception.hpp>
+#include <boost/asio/generic/basic_endpoint.hpp>
+
+#include <boost/asio/detail/push_options.hpp>
+
+namespace boost {
+namespace asio {
+namespace generic {
+
+/// Encapsulates the flags needed for a generic raw socket.
+/**
+ * The boost::asio::generic::raw_protocol class contains flags necessary for
+ * raw sockets of any address family and protocol.
+ *
+ * @par Examples
+ * Constructing using a native address family and socket protocol:
+ * @code raw_protocol p(AF_INET, IPPROTO_ICMP); @endcode
+ * Constructing from a specific protocol type:
+ * @code raw_protocol p(boost::asio::ip::icmp::v4()); @endcode
+ *
+ * @par Thread Safety
+ * @e Distinct @e objects: Safe._at_n
+ * @e Shared @e objects: Safe.
+ *
+ * @par Concepts:
+ * Protocol.
+ */
+class raw_protocol
+{
+public:
+ /// Construct a protocol object for a specific address family and protocol.
+ raw_protocol(int address_family, int socket_protocol)
+ : family_(address_family),
+ protocol_(socket_protocol)
+ {
+ }
+
+ /// Construct a generic protocol object from a specific protocol.
+ /**
+ * @throws @c bad_cast Thrown if the source protocol is not raw-oriented.
+ */
+ template <typename Protocol>
+ raw_protocol(const Protocol& source_protocol)
+ : family_(source_protocol.family()),
+ protocol_(source_protocol.protocol())
+ {
+ if (source_protocol.type() != type())
+ {
+ std::bad_cast ex;
+ boost::asio::detail::throw_exception(ex);
+ }
+ }
+
+ /// Obtain an identifier for the type of the protocol.
+ int type() const
+ {
+ return SOCK_RAW;
+ }
+
+ /// Obtain an identifier for the protocol.
+ int protocol() const
+ {
+ return protocol_;
+ }
+
+ /// Obtain an identifier for the protocol family.
+ int family() const
+ {
+ return family_;
+ }
+
+ /// Compare two protocols for equality.
+ friend bool operator==(const raw_protocol& p1, const raw_protocol& p2)
+ {
+ return p1.family_ == p2.family_ && p1.protocol_ == p2.protocol_;
+ }
+
+ /// Compare two protocols for inequality.
+ friend bool operator!=(const raw_protocol& p1, const raw_protocol& p2)
+ {
+ return !(p1 == p2);
+ }
+
+ /// The type of an endpoint.
+ typedef basic_endpoint<raw_protocol> endpoint;
+
+ /// The generic socket type.
+ typedef basic_raw_socket<raw_protocol> socket;
+
+private:
+ int family_;
+ int protocol_;
+};
+
+} // namespace generic
+} // namespace asio
+} // namespace boost
+
+#include <boost/asio/detail/pop_options.hpp>
+
+#endif // BOOST_ASIO_GENERIC_RAW_PROTOCOL_HPP
Added: trunk/boost/asio/generic/seq_packet_protocol.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/asio/generic/seq_packet_protocol.hpp 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -0,0 +1,124 @@
+//
+// generic/seq_packet_protocol.hpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2013 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_GENERIC_SEQ_PACKET_PROTOCOL_HPP
+#define BOOST_ASIO_GENERIC_SEQ_PACKET_PROTOCOL_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
+
+#include <boost/asio/detail/config.hpp>
+
+#include <typeinfo>
+#include <boost/asio/basic_seq_packet_socket.hpp>
+#include <boost/asio/detail/socket_types.hpp>
+#include <boost/asio/detail/throw_exception.hpp>
+#include <boost/asio/generic/basic_endpoint.hpp>
+
+#include <boost/asio/detail/push_options.hpp>
+
+namespace boost {
+namespace asio {
+namespace generic {
+
+/// Encapsulates the flags needed for a generic sequenced packet socket.
+/**
+ * The boost::asio::generic::seq_packet_protocol class contains flags necessary
+ * for seq_packet-oriented sockets of any address family and protocol.
+ *
+ * @par Examples
+ * Constructing using a native address family and socket protocol:
+ * @code seq_packet_protocol p(AF_INET, IPPROTO_SCTP); @endcode
+ *
+ * @par Thread Safety
+ * @e Distinct @e objects: Safe._at_n
+ * @e Shared @e objects: Safe.
+ *
+ * @par Concepts:
+ * Protocol.
+ */
+class seq_packet_protocol
+{
+public:
+ /// Construct a protocol object for a specific address family and protocol.
+ seq_packet_protocol(int address_family, int socket_protocol)
+ : family_(address_family),
+ protocol_(socket_protocol)
+ {
+ }
+
+ /// Construct a generic protocol object from a specific protocol.
+ /**
+ * @throws @c bad_cast Thrown if the source protocol is not based around
+ * sequenced packets.
+ */
+ template <typename Protocol>
+ seq_packet_protocol(const Protocol& source_protocol)
+ : family_(source_protocol.family()),
+ protocol_(source_protocol.protocol())
+ {
+ if (source_protocol.type() != type())
+ {
+ std::bad_cast ex;
+ boost::asio::detail::throw_exception(ex);
+ }
+ }
+
+ /// Obtain an identifier for the type of the protocol.
+ int type() const
+ {
+ return SOCK_SEQPACKET;
+ }
+
+ /// Obtain an identifier for the protocol.
+ int protocol() const
+ {
+ return protocol_;
+ }
+
+ /// Obtain an identifier for the protocol family.
+ int family() const
+ {
+ return family_;
+ }
+
+ /// Compare two protocols for equality.
+ friend bool operator==(const seq_packet_protocol& p1,
+ const seq_packet_protocol& p2)
+ {
+ return p1.family_ == p2.family_ && p1.protocol_ == p2.protocol_;
+ }
+
+ /// Compare two protocols for inequality.
+ friend bool operator!=(const seq_packet_protocol& p1,
+ const seq_packet_protocol& p2)
+ {
+ return !(p1 == p2);
+ }
+
+ /// The type of an endpoint.
+ typedef basic_endpoint<seq_packet_protocol> endpoint;
+
+ /// The generic socket type.
+ typedef basic_seq_packet_socket<seq_packet_protocol> socket;
+
+private:
+ int family_;
+ int protocol_;
+};
+
+} // namespace generic
+} // namespace asio
+} // namespace boost
+
+#include <boost/asio/detail/pop_options.hpp>
+
+#endif // BOOST_ASIO_GENERIC_SEQ_PACKET_PROTOCOL_HPP
Added: trunk/boost/asio/generic/stream_protocol.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/asio/generic/stream_protocol.hpp 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -0,0 +1,129 @@
+//
+// generic/stream_protocol.hpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2013 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_GENERIC_STREAM_PROTOCOL_HPP
+#define BOOST_ASIO_GENERIC_STREAM_PROTOCOL_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
+
+#include <boost/asio/detail/config.hpp>
+
+#include <typeinfo>
+#include <boost/asio/basic_socket_iostream.hpp>
+#include <boost/asio/basic_stream_socket.hpp>
+#include <boost/asio/detail/socket_types.hpp>
+#include <boost/asio/detail/throw_exception.hpp>
+#include <boost/asio/generic/basic_endpoint.hpp>
+
+#include <boost/asio/detail/push_options.hpp>
+
+namespace boost {
+namespace asio {
+namespace generic {
+
+/// Encapsulates the flags needed for a generic stream-oriented socket.
+/**
+ * The boost::asio::generic::stream_protocol class contains flags necessary for
+ * stream-oriented sockets of any address family and protocol.
+ *
+ * @par Examples
+ * Constructing using a native address family and socket protocol:
+ * @code stream_protocol p(AF_INET, IPPROTO_TCP); @endcode
+ * Constructing from a specific protocol type:
+ * @code stream_protocol p(boost::asio::ip::tcp::v4()); @endcode
+ *
+ * @par Thread Safety
+ * @e Distinct @e objects: Safe._at_n
+ * @e Shared @e objects: Safe.
+ *
+ * @par Concepts:
+ * Protocol.
+ */
+class stream_protocol
+{
+public:
+ /// Construct a protocol object for a specific address family and protocol.
+ stream_protocol(int address_family, int socket_protocol)
+ : family_(address_family),
+ protocol_(socket_protocol)
+ {
+ }
+
+ /// Construct a generic protocol object from a specific protocol.
+ /**
+ * @throws @c bad_cast Thrown if the source protocol is not stream-oriented.
+ */
+ template <typename Protocol>
+ stream_protocol(const Protocol& source_protocol)
+ : family_(source_protocol.family()),
+ protocol_(source_protocol.protocol())
+ {
+ if (source_protocol.type() != type())
+ {
+ std::bad_cast ex;
+ boost::asio::detail::throw_exception(ex);
+ }
+ }
+
+ /// Obtain an identifier for the type of the protocol.
+ int type() const
+ {
+ return SOCK_STREAM;
+ }
+
+ /// Obtain an identifier for the protocol.
+ int protocol() const
+ {
+ return protocol_;
+ }
+
+ /// Obtain an identifier for the protocol family.
+ int family() const
+ {
+ return family_;
+ }
+
+ /// Compare two protocols for equality.
+ friend bool operator==(const stream_protocol& p1, const stream_protocol& p2)
+ {
+ return p1.family_ == p2.family_ && p1.protocol_ == p2.protocol_;
+ }
+
+ /// Compare two protocols for inequality.
+ friend bool operator!=(const stream_protocol& p1, const stream_protocol& p2)
+ {
+ return !(p1 == p2);
+ }
+
+ /// The type of an endpoint.
+ typedef basic_endpoint<stream_protocol> endpoint;
+
+ /// The generic socket type.
+ typedef basic_stream_socket<stream_protocol> socket;
+
+#if !defined(BOOST_ASIO_NO_IOSTREAM)
+ /// The generic socket iostream type.
+ typedef basic_socket_iostream<stream_protocol> iostream;
+#endif // !defined(BOOST_ASIO_NO_IOSTREAM)
+
+private:
+ int family_;
+ int protocol_;
+};
+
+} // namespace generic
+} // namespace asio
+} // namespace boost
+
+#include <boost/asio/detail/pop_options.hpp>
+
+#endif // BOOST_ASIO_GENERIC_STREAM_PROTOCOL_HPP
Modified: trunk/boost/asio/impl/src.hpp
==============================================================================
--- trunk/boost/asio/impl/src.hpp (original)
+++ trunk/boost/asio/impl/src.hpp 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -59,6 +59,7 @@
#include <boost/asio/detail/impl/win_thread.ipp>
#include <boost/asio/detail/impl/win_tss_ptr.ipp>
#include <boost/asio/detail/impl/winsock_init.ipp>
+#include <boost/asio/generic/detail/impl/endpoint.ipp>
#include <boost/asio/ip/impl/address.ipp>
#include <boost/asio/ip/impl/address_v4.ipp>
#include <boost/asio/ip/impl/address_v6.ipp>
Modified: trunk/boost/asio/raw_socket_service.hpp
==============================================================================
--- trunk/boost/asio/raw_socket_service.hpp (original)
+++ trunk/boost/asio/raw_socket_service.hpp 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -18,6 +18,7 @@
#include <boost/asio/detail/config.hpp>
#include <cstddef>
#include <boost/asio/async_result.hpp>
+#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/io_service.hpp>
@@ -112,6 +113,19 @@
{
service_impl_.move_assign(impl, other_service.service_impl_, other_impl);
}
+
+ /// Move-construct a new raw socket implementation from another protocol
+ /// type.
+ template <typename Protocol1>
+ void converting_move_construct(implementation_type& impl,
+ typename raw_socket_service<
+ Protocol1>::implementation_type& other_impl,
+ typename enable_if<is_convertible<
+ Protocol1, Protocol>::value>::type* = 0)
+ {
+ service_impl_.template converting_move_construct<Protocol1>(
+ impl, other_impl);
+ }
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Destroy a raw socket implementation.
Modified: trunk/boost/asio/seq_packet_socket_service.hpp
==============================================================================
--- trunk/boost/asio/seq_packet_socket_service.hpp (original)
+++ trunk/boost/asio/seq_packet_socket_service.hpp 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -18,6 +18,7 @@
#include <boost/asio/detail/config.hpp>
#include <cstddef>
#include <boost/asio/async_result.hpp>
+#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/io_service.hpp>
@@ -114,6 +115,19 @@
{
service_impl_.move_assign(impl, other_service.service_impl_, other_impl);
}
+
+ /// Move-construct a new sequenced packet socket implementation from another
+ /// protocol type.
+ template <typename Protocol1>
+ void converting_move_construct(implementation_type& impl,
+ typename seq_packet_socket_service<
+ Protocol1>::implementation_type& other_impl,
+ typename enable_if<is_convertible<
+ Protocol1, Protocol>::value>::type* = 0)
+ {
+ service_impl_.template converting_move_construct<Protocol1>(
+ impl, other_impl);
+ }
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Destroy a sequenced packet socket implementation.
Modified: trunk/boost/asio/socket_acceptor_service.hpp
==============================================================================
--- trunk/boost/asio/socket_acceptor_service.hpp (original)
+++ trunk/boost/asio/socket_acceptor_service.hpp 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -17,6 +17,7 @@
#include <boost/asio/detail/config.hpp>
#include <boost/asio/basic_socket.hpp>
+#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/io_service.hpp>
@@ -111,6 +112,19 @@
{
service_impl_.move_assign(impl, other_service.service_impl_, other_impl);
}
+
+ /// Move-construct a new socket acceptor implementation from another protocol
+ /// type.
+ template <typename Protocol1>
+ void converting_move_construct(implementation_type& impl,
+ typename socket_acceptor_service<
+ Protocol1>::implementation_type& other_impl,
+ typename enable_if<is_convertible<
+ Protocol1, Protocol>::value>::type* = 0)
+ {
+ service_impl_.template converting_move_construct<Protocol1>(
+ impl, other_impl);
+ }
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Destroy a socket acceptor implementation.
@@ -239,22 +253,24 @@
}
/// Accept a new connection.
- template <typename SocketService>
+ template <typename Protocol1, typename SocketService>
boost::system::error_code accept(implementation_type& impl,
- basic_socket<protocol_type, SocketService>& peer,
- endpoint_type* peer_endpoint, boost::system::error_code& ec)
+ basic_socket<Protocol1, SocketService>& peer,
+ endpoint_type* peer_endpoint, boost::system::error_code& ec,
+ typename enable_if<is_convertible<Protocol, Protocol1>::value>::type* = 0)
{
return service_impl_.accept(impl, peer, peer_endpoint, ec);
}
/// Start an asynchronous accept.
- template <typename SocketService, typename AcceptHandler>
+ template <typename Protocol1, typename SocketService, typename AcceptHandler>
BOOST_ASIO_INITFN_RESULT_TYPE(AcceptHandler,
void (boost::system::error_code))
async_accept(implementation_type& impl,
- basic_socket<protocol_type, SocketService>& peer,
+ basic_socket<Protocol1, SocketService>& peer,
endpoint_type* peer_endpoint,
- BOOST_ASIO_MOVE_ARG(AcceptHandler) handler)
+ BOOST_ASIO_MOVE_ARG(AcceptHandler) handler,
+ typename enable_if<is_convertible<Protocol, Protocol1>::value>::type* = 0)
{
detail::async_result_init<
AcceptHandler, void (boost::system::error_code)> init(
Modified: trunk/boost/asio/stream_socket_service.hpp
==============================================================================
--- trunk/boost/asio/stream_socket_service.hpp (original)
+++ trunk/boost/asio/stream_socket_service.hpp 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -18,6 +18,7 @@
#include <boost/asio/detail/config.hpp>
#include <cstddef>
#include <boost/asio/async_result.hpp>
+#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/io_service.hpp>
@@ -112,6 +113,19 @@
{
service_impl_.move_assign(impl, other_service.service_impl_, other_impl);
}
+
+ /// Move-construct a new stream socket implementation from another protocol
+ /// type.
+ template <typename Protocol1>
+ void converting_move_construct(implementation_type& impl,
+ typename stream_socket_service<
+ Protocol1>::implementation_type& other_impl,
+ typename enable_if<is_convertible<
+ Protocol1, Protocol>::value>::type* = 0)
+ {
+ service_impl_.template converting_move_construct<Protocol1>(
+ impl, other_impl);
+ }
#endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Destroy a stream socket implementation.
Modified: trunk/libs/asio/doc/reference.xsl
==============================================================================
--- trunk/libs/asio/doc/reference.xsl (original)
+++ trunk/libs/asio/doc/reference.xsl 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -1443,6 +1443,9 @@
<xsl:when test="declname = 'Context_Service'">
<xsl:value-of select="declname"/>
</xsl:when>
+ <xsl:when test="declname = 'DatagramSocketService1'">
+ <xsl:value-of select="concat('``[link boost_asio.reference.DatagramSocketService ', declname, ']``')"/>
+ </xsl:when>
<xsl:when test="declname = 'Elem'">
<xsl:value-of select="declname"/>
</xsl:when>
@@ -1470,12 +1473,24 @@
<xsl:when test="declname = 'PointerToPodType'">
<xsl:value-of select="declname"/>
</xsl:when>
+ <xsl:when test="declname = 'Protocol1'">
+ <xsl:value-of select="concat('``[link boost_asio.reference.Protocol ', declname, ']``')"/>
+ </xsl:when>
+ <xsl:when test="declname = 'RawSocketService1'">
+ <xsl:value-of select="concat('``[link boost_asio.reference.RawSocketService ', declname, ']``')"/>
+ </xsl:when>
+ <xsl:when test="declname = 'SeqPacketSocketService1'">
+ <xsl:value-of select="concat('``[link boost_asio.reference.SeqPacketSocketService ', declname, ']``')"/>
+ </xsl:when>
<xsl:when test="declname = 'SocketService1' or declname = 'SocketService2'">
<xsl:value-of select="concat('``[link boost_asio.reference.SocketService ', declname, ']``')"/>
</xsl:when>
<xsl:when test="declname = 'Stream'">
<xsl:value-of select="declname"/>
</xsl:when>
+ <xsl:when test="declname = 'StreamSocketService1'">
+ <xsl:value-of select="concat('``[link boost_asio.reference.StreamSocketService ', declname, ']``')"/>
+ </xsl:when>
<xsl:when test="declname = 'T'">
<xsl:value-of select="declname"/>
</xsl:when>
Modified: trunk/libs/asio/test/Jamfile
==============================================================================
--- trunk/libs/asio/test/Jamfile (original)
+++ trunk/libs/asio/test/Jamfile 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -59,6 +59,11 @@
[ run deadline_timer_service.cpp <template>asio_unit_test ]
[ run deadline_timer.cpp <template>asio_unit_test ]
[ run error.cpp <template>asio_unit_test ]
+ [ run generic/basic_endpoint.cpp <template>asio_unit_test ]
+ [ run generic/datagram_protocol.cpp <template>asio_unit_test ]
+ [ run generic/raw_protocol.cpp <template>asio_unit_test ]
+ [ run generic/seq_packet_protocol.cpp <template>asio_unit_test ]
+ [ run generic/stream_protocol.cpp <template>asio_unit_test ]
[ run io_service.cpp <template>asio_unit_test ]
[ run ip/address.cpp <template>asio_unit_test ]
[ run ip/address_v4.cpp <template>asio_unit_test ]
Modified: trunk/libs/asio/test/Jamfile.v2
==============================================================================
--- trunk/libs/asio/test/Jamfile.v2 (original)
+++ trunk/libs/asio/test/Jamfile.v2 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -103,6 +103,16 @@
[ run deadline_timer.cpp : : : $(USE_SELECT) : deadline_timer_select ]
[ run error.cpp ]
[ run error.cpp : : : $(USE_SELECT) : error_select ]
+ [ link generic/basic_endpoint.cpp : : generic_basic_endpoint ]
+ [ link generic/basic_endpoint.cpp : $(USE_SELECT) : generic_basic_endpoint_select ]
+ [ link generic/datagram_protocol.cpp : : generic_datagram_protocol ]
+ [ link generic/datagram_protocol.cpp : $(USE_SELECT) : generic_datagram_protocol_select ]
+ [ link generic/raw_protocol.cpp : : generic_raw_protocol ]
+ [ link generic/raw_protocol.cpp : $(USE_SELECT) : generic_raw_protocol_select ]
+ [ link generic/seq_packet_protocol.cpp : : generic_seq_packet_protocol ]
+ [ link generic/seq_packet_protocol.cpp : $(USE_SELECT) : generic_seq_packet_protocol_select ]
+ [ link generic/stream_protocol.cpp : : generic_stream_protocol ]
+ [ link generic/stream_protocol.cpp : $(USE_SELECT) : generic_stream_protocol_select ]
[ link high_resolution_timer.cpp ]
[ link high_resolution_timer.cpp : $(USE_SELECT) : high_resolution_timer_select ]
[ run io_service.cpp ]
Added: trunk/libs/asio/test/generic/basic_endpoint.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/asio/test/generic/basic_endpoint.cpp 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -0,0 +1,25 @@
+//
+// generic/basic_endpoint.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2013 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)
+//
+
+// Disable autolinking for unit tests.
+#if !defined(BOOST_ALL_NO_LIB)
+#define BOOST_ALL_NO_LIB 1
+#endif // !defined(BOOST_ALL_NO_LIB)
+
+// Test that header file is self-contained.
+#include <boost/asio/generic/basic_endpoint.hpp>
+
+#include "../unit_test.hpp"
+
+BOOST_ASIO_TEST_SUITE
+(
+ "generic/basic_endpoint",
+ BOOST_ASIO_TEST_CASE(null_test)
+)
Added: trunk/libs/asio/test/generic/datagram_protocol.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/asio/test/generic/datagram_protocol.cpp 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -0,0 +1,243 @@
+//
+// generic/datagram_protocol.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2013 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)
+//
+
+// Disable autolinking for unit tests.
+#if !defined(BOOST_ALL_NO_LIB)
+#define BOOST_ALL_NO_LIB 1
+#endif // !defined(BOOST_ALL_NO_LIB)
+
+// Test that header file is self-contained.
+#include <boost/asio/generic/datagram_protocol.hpp>
+
+#include <cstring>
+#include <boost/asio/io_service.hpp>
+#include <boost/asio/ip/udp.hpp>
+#include "../unit_test.hpp"
+
+//------------------------------------------------------------------------------
+
+// generic_datagram_protocol_socket_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// generic::datagram_socket::socket compile and link correctly. Runtime
+// failures are ignored.
+
+namespace generic_datagram_protocol_socket_compile {
+
+void connect_handler(const boost::system::error_code&)
+{
+}
+
+void send_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void receive_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void test()
+{
+ using namespace boost::asio;
+ namespace generic = boost::asio::generic;
+ typedef generic::datagram_protocol dp;
+
+ try
+ {
+ io_service ios;
+ char mutable_char_buffer[128] = "";
+ const char const_char_buffer[128] = "";
+ socket_base::message_flags in_flags = 0;
+ socket_base::send_buffer_size socket_option;
+ socket_base::bytes_readable io_control_command;
+ boost::system::error_code ec;
+
+ // basic_datagram_socket constructors.
+
+ dp::socket socket1(ios);
+ dp::socket socket2(ios, dp(AF_INET, IPPROTO_UDP));
+ dp::socket socket3(ios, dp::endpoint());
+ int native_socket1 = ::socket(AF_INET, SOCK_DGRAM, 0);
+ dp::socket socket4(ios, dp(AF_INET, IPPROTO_UDP), native_socket1);
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ dp::socket socket5(std::move(socket4));
+ dp::socket socket6(boost::asio::ip::udp::socket(ios));
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_datagram_socket operators.
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ socket1 = dp::socket(ios);
+ socket1 = std::move(socket2);
+ socket1 = boost::asio::ip::udp::socket(ios);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_io_object functions.
+
+ io_service& ios_ref = socket1.get_io_service();
+ (void)ios_ref;
+
+ // basic_socket functions.
+
+ dp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer();
+ (void)lowest_layer;
+
+ socket1.open(dp(AF_INET, IPPROTO_UDP));
+ socket1.open(dp(AF_INET, IPPROTO_UDP), ec);
+
+ int native_socket2 = ::socket(AF_INET, SOCK_DGRAM, 0);
+ socket1.assign(dp(AF_INET, IPPROTO_UDP), native_socket2);
+ int native_socket3 = ::socket(AF_INET, SOCK_DGRAM, 0);
+ socket1.assign(dp(AF_INET, IPPROTO_UDP), native_socket3, ec);
+
+ bool is_open = socket1.is_open();
+ (void)is_open;
+
+ socket1.close();
+ socket1.close(ec);
+
+ dp::socket::native_type native_socket4 = socket1.native();
+ (void)native_socket4;
+
+ socket1.cancel();
+ socket1.cancel(ec);
+
+ bool at_mark1 = socket1.at_mark();
+ (void)at_mark1;
+ bool at_mark2 = socket1.at_mark(ec);
+ (void)at_mark2;
+
+ std::size_t available1 = socket1.available();
+ (void)available1;
+ std::size_t available2 = socket1.available(ec);
+ (void)available2;
+
+ socket1.bind(dp::endpoint());
+ socket1.bind(dp::endpoint(), ec);
+
+ socket1.connect(dp::endpoint());
+ socket1.connect(dp::endpoint(), ec);
+
+ socket1.async_connect(dp::endpoint(), connect_handler);
+
+ socket1.set_option(socket_option);
+ socket1.set_option(socket_option, ec);
+
+ socket1.get_option(socket_option);
+ socket1.get_option(socket_option, ec);
+
+ socket1.io_control(io_control_command);
+ socket1.io_control(io_control_command, ec);
+
+ dp::endpoint endpoint1 = socket1.local_endpoint();
+ dp::endpoint endpoint2 = socket1.local_endpoint(ec);
+
+ dp::endpoint endpoint3 = socket1.remote_endpoint();
+ dp::endpoint endpoint4 = socket1.remote_endpoint(ec);
+
+ socket1.shutdown(socket_base::shutdown_both);
+ socket1.shutdown(socket_base::shutdown_both, ec);
+
+ // basic_datagram_socket functions.
+
+ socket1.send(buffer(mutable_char_buffer));
+ socket1.send(buffer(const_char_buffer));
+ socket1.send(null_buffers());
+ socket1.send(buffer(mutable_char_buffer), in_flags);
+ socket1.send(buffer(const_char_buffer), in_flags);
+ socket1.send(null_buffers(), in_flags);
+ socket1.send(buffer(mutable_char_buffer), in_flags, ec);
+ socket1.send(buffer(const_char_buffer), in_flags, ec);
+ socket1.send(null_buffers(), in_flags, ec);
+
+ socket1.async_send(buffer(mutable_char_buffer), send_handler);
+ socket1.async_send(buffer(const_char_buffer), send_handler);
+ socket1.async_send(null_buffers(), send_handler);
+ socket1.async_send(buffer(mutable_char_buffer), in_flags, send_handler);
+ socket1.async_send(buffer(const_char_buffer), in_flags, send_handler);
+ socket1.async_send(null_buffers(), in_flags, send_handler);
+
+ socket1.send_to(buffer(mutable_char_buffer),
+ dp::endpoint());
+ socket1.send_to(buffer(const_char_buffer),
+ dp::endpoint());
+ socket1.send_to(null_buffers(),
+ dp::endpoint());
+ socket1.send_to(buffer(mutable_char_buffer),
+ dp::endpoint(), in_flags);
+ socket1.send_to(buffer(const_char_buffer),
+ dp::endpoint(), in_flags);
+ socket1.send_to(null_buffers(),
+ dp::endpoint(), in_flags);
+ socket1.send_to(buffer(mutable_char_buffer),
+ dp::endpoint(), in_flags, ec);
+ socket1.send_to(buffer(const_char_buffer),
+ dp::endpoint(), in_flags, ec);
+ socket1.send_to(null_buffers(),
+ dp::endpoint(), in_flags, ec);
+
+ socket1.async_send_to(buffer(mutable_char_buffer),
+ dp::endpoint(), send_handler);
+ socket1.async_send_to(buffer(const_char_buffer),
+ dp::endpoint(), send_handler);
+ socket1.async_send_to(null_buffers(),
+ dp::endpoint(), send_handler);
+ socket1.async_send_to(buffer(mutable_char_buffer),
+ dp::endpoint(), in_flags, send_handler);
+ socket1.async_send_to(buffer(const_char_buffer),
+ dp::endpoint(), in_flags, send_handler);
+ socket1.async_send_to(null_buffers(),
+ dp::endpoint(), in_flags, send_handler);
+
+ socket1.receive(buffer(mutable_char_buffer));
+ socket1.receive(null_buffers());
+ socket1.receive(buffer(mutable_char_buffer), in_flags);
+ socket1.receive(null_buffers(), in_flags);
+ socket1.receive(buffer(mutable_char_buffer), in_flags, ec);
+ socket1.receive(null_buffers(), in_flags, ec);
+
+ socket1.async_receive(buffer(mutable_char_buffer), receive_handler);
+ socket1.async_receive(null_buffers(), receive_handler);
+ socket1.async_receive(buffer(mutable_char_buffer), in_flags,
+ receive_handler);
+ socket1.async_receive(null_buffers(), in_flags, receive_handler);
+
+ dp::endpoint endpoint;
+ socket1.receive_from(buffer(mutable_char_buffer), endpoint);
+ socket1.receive_from(null_buffers(), endpoint);
+ socket1.receive_from(buffer(mutable_char_buffer), endpoint, in_flags);
+ socket1.receive_from(null_buffers(), endpoint, in_flags);
+ socket1.receive_from(buffer(mutable_char_buffer), endpoint, in_flags, ec);
+ socket1.receive_from(null_buffers(), endpoint, in_flags, ec);
+
+ socket1.async_receive_from(buffer(mutable_char_buffer),
+ endpoint, receive_handler);
+ socket1.async_receive_from(null_buffers(),
+ endpoint, receive_handler);
+ socket1.async_receive_from(buffer(mutable_char_buffer),
+ endpoint, in_flags, receive_handler);
+ socket1.async_receive_from(null_buffers(),
+ endpoint, in_flags, receive_handler);
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace generic_datagram_protocol_socket_compile
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "generic/datagram_protocol",
+ BOOST_ASIO_TEST_CASE(generic_datagram_protocol_socket_compile::test)
+)
Added: trunk/libs/asio/test/generic/raw_protocol.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/asio/test/generic/raw_protocol.cpp 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -0,0 +1,243 @@
+//
+// generic/raw_protocol.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2013 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)
+//
+
+// Disable autolinking for unit tests.
+#if !defined(BOOST_ALL_NO_LIB)
+#define BOOST_ALL_NO_LIB 1
+#endif // !defined(BOOST_ALL_NO_LIB)
+
+// Test that header file is self-contained.
+#include <boost/asio/generic/raw_protocol.hpp>
+
+#include <cstring>
+#include <boost/asio/io_service.hpp>
+#include <boost/asio/ip/icmp.hpp>
+#include "../unit_test.hpp"
+
+//------------------------------------------------------------------------------
+
+// generic_raw_protocol_socket_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// generic::raw_socket::socket compile and link correctly. Runtime failures
+// are ignored.
+
+namespace generic_raw_protocol_socket_compile {
+
+void connect_handler(const boost::system::error_code&)
+{
+}
+
+void send_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void receive_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void test()
+{
+ using namespace boost::asio;
+ namespace generic = boost::asio::generic;
+ typedef generic::raw_protocol rp;
+
+ try
+ {
+ io_service ios;
+ char mutable_char_buffer[128] = "";
+ const char const_char_buffer[128] = "";
+ socket_base::message_flags in_flags = 0;
+ socket_base::send_buffer_size socket_option;
+ socket_base::bytes_readable io_control_command;
+ boost::system::error_code ec;
+
+ // basic_raw_socket constructors.
+
+ rp::socket socket1(ios);
+ rp::socket socket2(ios, rp(AF_INET, IPPROTO_ICMP));
+ rp::socket socket3(ios, rp::endpoint());
+ int native_socket1 = ::socket(AF_INET, SOCK_DGRAM, 0);
+ rp::socket socket4(ios, rp(AF_INET, IPPROTO_ICMP), native_socket1);
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ rp::socket socket5(std::move(socket4));
+ rp::socket socket6(boost::asio::ip::icmp::socket(ios));
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_datagram_socket operators.
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ socket1 = rp::socket(ios);
+ socket1 = std::move(socket2);
+ socket1 = boost::asio::ip::icmp::socket(ios);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_io_object functions.
+
+ io_service& ios_ref = socket1.get_io_service();
+ (void)ios_ref;
+
+ // basic_socket functions.
+
+ rp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer();
+ (void)lowest_layer;
+
+ socket1.open(rp(AF_INET, IPPROTO_ICMP));
+ socket1.open(rp(AF_INET, IPPROTO_ICMP), ec);
+
+ int native_socket2 = ::socket(AF_INET, SOCK_DGRAM, 0);
+ socket1.assign(rp(AF_INET, IPPROTO_ICMP), native_socket2);
+ int native_socket3 = ::socket(AF_INET, SOCK_DGRAM, 0);
+ socket1.assign(rp(AF_INET, IPPROTO_ICMP), native_socket3, ec);
+
+ bool is_open = socket1.is_open();
+ (void)is_open;
+
+ socket1.close();
+ socket1.close(ec);
+
+ rp::socket::native_type native_socket4 = socket1.native();
+ (void)native_socket4;
+
+ socket1.cancel();
+ socket1.cancel(ec);
+
+ bool at_mark1 = socket1.at_mark();
+ (void)at_mark1;
+ bool at_mark2 = socket1.at_mark(ec);
+ (void)at_mark2;
+
+ std::size_t available1 = socket1.available();
+ (void)available1;
+ std::size_t available2 = socket1.available(ec);
+ (void)available2;
+
+ socket1.bind(rp::endpoint());
+ socket1.bind(rp::endpoint(), ec);
+
+ socket1.connect(rp::endpoint());
+ socket1.connect(rp::endpoint(), ec);
+
+ socket1.async_connect(rp::endpoint(), connect_handler);
+
+ socket1.set_option(socket_option);
+ socket1.set_option(socket_option, ec);
+
+ socket1.get_option(socket_option);
+ socket1.get_option(socket_option, ec);
+
+ socket1.io_control(io_control_command);
+ socket1.io_control(io_control_command, ec);
+
+ rp::endpoint endpoint1 = socket1.local_endpoint();
+ rp::endpoint endpoint2 = socket1.local_endpoint(ec);
+
+ rp::endpoint endpoint3 = socket1.remote_endpoint();
+ rp::endpoint endpoint4 = socket1.remote_endpoint(ec);
+
+ socket1.shutdown(socket_base::shutdown_both);
+ socket1.shutdown(socket_base::shutdown_both, ec);
+
+ // basic_raw_socket functions.
+
+ socket1.send(buffer(mutable_char_buffer));
+ socket1.send(buffer(const_char_buffer));
+ socket1.send(null_buffers());
+ socket1.send(buffer(mutable_char_buffer), in_flags);
+ socket1.send(buffer(const_char_buffer), in_flags);
+ socket1.send(null_buffers(), in_flags);
+ socket1.send(buffer(mutable_char_buffer), in_flags, ec);
+ socket1.send(buffer(const_char_buffer), in_flags, ec);
+ socket1.send(null_buffers(), in_flags, ec);
+
+ socket1.async_send(buffer(mutable_char_buffer), send_handler);
+ socket1.async_send(buffer(const_char_buffer), send_handler);
+ socket1.async_send(null_buffers(), send_handler);
+ socket1.async_send(buffer(mutable_char_buffer), in_flags, send_handler);
+ socket1.async_send(buffer(const_char_buffer), in_flags, send_handler);
+ socket1.async_send(null_buffers(), in_flags, send_handler);
+
+ socket1.send_to(buffer(mutable_char_buffer),
+ rp::endpoint());
+ socket1.send_to(buffer(const_char_buffer),
+ rp::endpoint());
+ socket1.send_to(null_buffers(),
+ rp::endpoint());
+ socket1.send_to(buffer(mutable_char_buffer),
+ rp::endpoint(), in_flags);
+ socket1.send_to(buffer(const_char_buffer),
+ rp::endpoint(), in_flags);
+ socket1.send_to(null_buffers(),
+ rp::endpoint(), in_flags);
+ socket1.send_to(buffer(mutable_char_buffer),
+ rp::endpoint(), in_flags, ec);
+ socket1.send_to(buffer(const_char_buffer),
+ rp::endpoint(), in_flags, ec);
+ socket1.send_to(null_buffers(),
+ rp::endpoint(), in_flags, ec);
+
+ socket1.async_send_to(buffer(mutable_char_buffer),
+ rp::endpoint(), send_handler);
+ socket1.async_send_to(buffer(const_char_buffer),
+ rp::endpoint(), send_handler);
+ socket1.async_send_to(null_buffers(),
+ rp::endpoint(), send_handler);
+ socket1.async_send_to(buffer(mutable_char_buffer),
+ rp::endpoint(), in_flags, send_handler);
+ socket1.async_send_to(buffer(const_char_buffer),
+ rp::endpoint(), in_flags, send_handler);
+ socket1.async_send_to(null_buffers(),
+ rp::endpoint(), in_flags, send_handler);
+
+ socket1.receive(buffer(mutable_char_buffer));
+ socket1.receive(null_buffers());
+ socket1.receive(buffer(mutable_char_buffer), in_flags);
+ socket1.receive(null_buffers(), in_flags);
+ socket1.receive(buffer(mutable_char_buffer), in_flags, ec);
+ socket1.receive(null_buffers(), in_flags, ec);
+
+ socket1.async_receive(buffer(mutable_char_buffer), receive_handler);
+ socket1.async_receive(null_buffers(), receive_handler);
+ socket1.async_receive(buffer(mutable_char_buffer), in_flags,
+ receive_handler);
+ socket1.async_receive(null_buffers(), in_flags, receive_handler);
+
+ rp::endpoint endpoint;
+ socket1.receive_from(buffer(mutable_char_buffer), endpoint);
+ socket1.receive_from(null_buffers(), endpoint);
+ socket1.receive_from(buffer(mutable_char_buffer), endpoint, in_flags);
+ socket1.receive_from(null_buffers(), endpoint, in_flags);
+ socket1.receive_from(buffer(mutable_char_buffer), endpoint, in_flags, ec);
+ socket1.receive_from(null_buffers(), endpoint, in_flags, ec);
+
+ socket1.async_receive_from(buffer(mutable_char_buffer),
+ endpoint, receive_handler);
+ socket1.async_receive_from(null_buffers(),
+ endpoint, receive_handler);
+ socket1.async_receive_from(buffer(mutable_char_buffer),
+ endpoint, in_flags, receive_handler);
+ socket1.async_receive_from(null_buffers(),
+ endpoint, in_flags, receive_handler);
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace generic_raw_protocol_socket_compile
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "generic/raw_protocol",
+ BOOST_ASIO_TEST_CASE(generic_raw_protocol_socket_compile::test)
+)
Added: trunk/libs/asio/test/generic/seq_packet_protocol.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/asio/test/generic/seq_packet_protocol.cpp 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -0,0 +1,187 @@
+//
+// generic/seq_packet_protocol.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2013 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)
+//
+
+// Disable autolinking for unit tests.
+#if !defined(BOOST_ALL_NO_LIB)
+#define BOOST_ALL_NO_LIB 1
+#endif // !defined(BOOST_ALL_NO_LIB)
+
+// Test that header file is self-contained.
+#include <boost/asio/generic/seq_packet_protocol.hpp>
+
+#include <cstring>
+#include <boost/asio/io_service.hpp>
+#include "../unit_test.hpp"
+
+//------------------------------------------------------------------------------
+
+// generic_seq_packet_protocol_socket_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// generic::seq_packet_socket::socket compile and link correctly. Runtime
+// failures are ignored.
+
+namespace generic_seq_packet_protocol_socket_compile {
+
+void connect_handler(const boost::system::error_code&)
+{
+}
+
+void send_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void receive_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void test()
+{
+ using namespace boost::asio;
+ namespace generic = boost::asio::generic;
+ typedef generic::seq_packet_protocol spp;
+
+ try
+ {
+ io_service ios;
+ char mutable_char_buffer[128] = "";
+ const char const_char_buffer[128] = "";
+ const socket_base::message_flags in_flags = 0;
+ socket_base::message_flags out_flags = 0;
+ socket_base::send_buffer_size socket_option;
+ socket_base::bytes_readable io_control_command;
+ boost::system::error_code ec;
+
+ // basic_seq_packet_socket constructors.
+
+ spp::socket socket1(ios);
+ spp::socket socket2(ios, spp(AF_INET, 0));
+ spp::socket socket3(ios, spp::endpoint());
+ int native_socket1 = ::socket(AF_INET, SOCK_SEQPACKET, 0);
+ spp::socket socket4(ios, spp(AF_INET, 0), native_socket1);
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ spp::socket socket5(std::move(socket4));
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_seq_packet_socket operators.
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ socket1 = spp::socket(ios);
+ socket1 = std::move(socket2);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_io_object functions.
+
+ io_service& ios_ref = socket1.get_io_service();
+ (void)ios_ref;
+
+ // basic_socket functions.
+
+ spp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer();
+ (void)lowest_layer;
+
+ socket1.open(spp(AF_INET, 0));
+ socket1.open(spp(AF_INET, 0), ec);
+
+ int native_socket2 = ::socket(AF_INET, SOCK_SEQPACKET, 0);
+ socket1.assign(spp(AF_INET, 0), native_socket2);
+ int native_socket3 = ::socket(AF_INET, SOCK_SEQPACKET, 0);
+ socket1.assign(spp(AF_INET, 0), native_socket3, ec);
+
+ bool is_open = socket1.is_open();
+ (void)is_open;
+
+ socket1.close();
+ socket1.close(ec);
+
+ spp::socket::native_type native_socket4 = socket1.native();
+ (void)native_socket4;
+
+ socket1.cancel();
+ socket1.cancel(ec);
+
+ bool at_mark1 = socket1.at_mark();
+ (void)at_mark1;
+ bool at_mark2 = socket1.at_mark(ec);
+ (void)at_mark2;
+
+ std::size_t available1 = socket1.available();
+ (void)available1;
+ std::size_t available2 = socket1.available(ec);
+ (void)available2;
+
+ socket1.bind(spp::endpoint());
+ socket1.bind(spp::endpoint(), ec);
+
+ socket1.connect(spp::endpoint());
+ socket1.connect(spp::endpoint(), ec);
+
+ socket1.async_connect(spp::endpoint(), connect_handler);
+
+ socket1.set_option(socket_option);
+ socket1.set_option(socket_option, ec);
+
+ socket1.get_option(socket_option);
+ socket1.get_option(socket_option, ec);
+
+ socket1.io_control(io_control_command);
+ socket1.io_control(io_control_command, ec);
+
+ spp::endpoint endpoint1 = socket1.local_endpoint();
+ spp::endpoint endpoint2 = socket1.local_endpoint(ec);
+
+ spp::endpoint endpoint3 = socket1.remote_endpoint();
+ spp::endpoint endpoint4 = socket1.remote_endpoint(ec);
+
+ socket1.shutdown(socket_base::shutdown_both);
+ socket1.shutdown(socket_base::shutdown_both, ec);
+
+ // basic_seq_packet_socket functions.
+
+ socket1.send(buffer(mutable_char_buffer), in_flags);
+ socket1.send(buffer(const_char_buffer), in_flags);
+ socket1.send(null_buffers(), in_flags);
+ socket1.send(buffer(mutable_char_buffer), in_flags, ec);
+ socket1.send(buffer(const_char_buffer), in_flags, ec);
+ socket1.send(null_buffers(), in_flags, ec);
+
+ socket1.async_send(buffer(mutable_char_buffer), in_flags, send_handler);
+ socket1.async_send(buffer(const_char_buffer), in_flags, send_handler);
+ socket1.async_send(null_buffers(), in_flags, send_handler);
+
+ socket1.receive(buffer(mutable_char_buffer), out_flags);
+ socket1.receive(null_buffers(), out_flags);
+ socket1.receive(buffer(mutable_char_buffer), in_flags, out_flags);
+ socket1.receive(null_buffers(), in_flags, out_flags);
+ socket1.receive(buffer(mutable_char_buffer), in_flags, out_flags, ec);
+ socket1.receive(null_buffers(), in_flags, out_flags, ec);
+
+ socket1.async_receive(buffer(mutable_char_buffer), out_flags,
+ receive_handler);
+ socket1.async_receive(null_buffers(), out_flags, receive_handler);
+ socket1.async_receive(buffer(mutable_char_buffer), in_flags,
+ out_flags, receive_handler);
+ socket1.async_receive(null_buffers(), in_flags, out_flags, receive_handler);
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace generic_seq_packet_protocol_socket_compile
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "generic/seq_packet_protocol",
+ BOOST_ASIO_TEST_CASE(generic_seq_packet_protocol_socket_compile::test)
+)
Added: trunk/libs/asio/test/generic/stream_protocol.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/asio/test/generic/stream_protocol.cpp 2013-05-19 00:55:11 EDT (Sun, 19 May 2013)
@@ -0,0 +1,220 @@
+//
+// generic/stream_protocol.cpp
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2013 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)
+//
+
+// Disable autolinking for unit tests.
+#if !defined(BOOST_ALL_NO_LIB)
+#define BOOST_ALL_NO_LIB 1
+#endif // !defined(BOOST_ALL_NO_LIB)
+
+// Test that header file is self-contained.
+#include <boost/asio/generic/stream_protocol.hpp>
+
+#include <cstring>
+#include <boost/asio/io_service.hpp>
+#include <boost/asio/ip/tcp.hpp>
+#include "../unit_test.hpp"
+
+//------------------------------------------------------------------------------
+
+// generic_stream_protocol_socket_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// generic::stream_protocol::socket compile and link correctly. Runtime
+// failures are ignored.
+
+namespace generic_stream_protocol_socket_compile {
+
+void connect_handler(const boost::system::error_code&)
+{
+}
+
+void send_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void receive_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void write_some_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void read_some_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void test()
+{
+ using namespace boost::asio;
+ namespace generic = boost::asio::generic;
+ typedef generic::stream_protocol sp;
+
+ try
+ {
+ io_service ios;
+ char mutable_char_buffer[128] = "";
+ const char const_char_buffer[128] = "";
+ socket_base::message_flags in_flags = 0;
+ socket_base::keep_alive socket_option;
+ socket_base::bytes_readable io_control_command;
+ boost::system::error_code ec;
+
+ // basic_stream_socket constructors.
+
+ sp::socket socket1(ios);
+ sp::socket socket2(ios, sp(AF_INET, IPPROTO_TCP));
+ sp::socket socket3(ios, sp::endpoint());
+ int native_socket1 = ::socket(AF_INET, SOCK_STREAM, 0);
+ sp::socket socket4(ios, sp(AF_INET, IPPROTO_TCP), native_socket1);
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ sp::socket socket5(std::move(socket4));
+ sp::socket socket6(boost::asio::ip::tcp::socket(ios));
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_stream_socket operators.
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ socket1 = sp::socket(ios);
+ socket1 = std::move(socket2);
+ socket1 = boost::asio::ip::tcp::socket(ios);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_io_object functions.
+
+ io_service& ios_ref = socket1.get_io_service();
+ (void)ios_ref;
+
+ // basic_socket functions.
+
+ sp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer();
+ (void)lowest_layer;
+
+ socket1.open(sp(AF_INET, IPPROTO_TCP));
+ socket1.open(sp(AF_INET, IPPROTO_TCP), ec);
+
+ int native_socket2 = ::socket(AF_INET, SOCK_STREAM, 0);
+ socket1.assign(sp(AF_INET, IPPROTO_TCP), native_socket2);
+ int native_socket3 = ::socket(AF_INET, SOCK_STREAM, 0);
+ socket1.assign(sp(AF_INET, IPPROTO_TCP), native_socket3, ec);
+
+ bool is_open = socket1.is_open();
+ (void)is_open;
+
+ socket1.close();
+ socket1.close(ec);
+
+ sp::socket::native_type native_socket4 = socket1.native();
+ (void)native_socket4;
+
+ socket1.cancel();
+ socket1.cancel(ec);
+
+ bool at_mark1 = socket1.at_mark();
+ (void)at_mark1;
+ bool at_mark2 = socket1.at_mark(ec);
+ (void)at_mark2;
+
+ std::size_t available1 = socket1.available();
+ (void)available1;
+ std::size_t available2 = socket1.available(ec);
+ (void)available2;
+
+ socket1.bind(sp::endpoint());
+ socket1.bind(sp::endpoint(), ec);
+
+ socket1.connect(sp::endpoint());
+ socket1.connect(sp::endpoint(), ec);
+
+ socket1.async_connect(sp::endpoint(), connect_handler);
+
+ socket1.set_option(socket_option);
+ socket1.set_option(socket_option, ec);
+
+ socket1.get_option(socket_option);
+ socket1.get_option(socket_option, ec);
+
+ socket1.io_control(io_control_command);
+ socket1.io_control(io_control_command, ec);
+
+ sp::endpoint endpoint1 = socket1.local_endpoint();
+ sp::endpoint endpoint2 = socket1.local_endpoint(ec);
+
+ sp::endpoint endpoint3 = socket1.remote_endpoint();
+ sp::endpoint endpoint4 = socket1.remote_endpoint(ec);
+
+ socket1.shutdown(socket_base::shutdown_both);
+ socket1.shutdown(socket_base::shutdown_both, ec);
+
+ // basic_stream_socket functions.
+
+ socket1.send(buffer(mutable_char_buffer));
+ socket1.send(buffer(const_char_buffer));
+ socket1.send(null_buffers());
+ socket1.send(buffer(mutable_char_buffer), in_flags);
+ socket1.send(buffer(const_char_buffer), in_flags);
+ socket1.send(null_buffers(), in_flags);
+ socket1.send(buffer(mutable_char_buffer), in_flags, ec);
+ socket1.send(buffer(const_char_buffer), in_flags, ec);
+ socket1.send(null_buffers(), in_flags, ec);
+
+ socket1.async_send(buffer(mutable_char_buffer), send_handler);
+ socket1.async_send(buffer(const_char_buffer), send_handler);
+ socket1.async_send(null_buffers(), send_handler);
+ socket1.async_send(buffer(mutable_char_buffer), in_flags, send_handler);
+ socket1.async_send(buffer(const_char_buffer), in_flags, send_handler);
+ socket1.async_send(null_buffers(), in_flags, send_handler);
+
+ socket1.receive(buffer(mutable_char_buffer));
+ socket1.receive(null_buffers());
+ socket1.receive(buffer(mutable_char_buffer), in_flags);
+ socket1.receive(null_buffers(), in_flags);
+ socket1.receive(buffer(mutable_char_buffer), in_flags, ec);
+ socket1.receive(null_buffers(), in_flags, ec);
+
+ socket1.async_receive(buffer(mutable_char_buffer), receive_handler);
+ socket1.async_receive(null_buffers(), receive_handler);
+ socket1.async_receive(buffer(mutable_char_buffer), in_flags,
+ receive_handler);
+ socket1.async_receive(null_buffers(), in_flags, receive_handler);
+
+ socket1.write_some(buffer(mutable_char_buffer));
+ socket1.write_some(buffer(const_char_buffer));
+ socket1.write_some(null_buffers());
+ socket1.write_some(buffer(mutable_char_buffer), ec);
+ socket1.write_some(buffer(const_char_buffer), ec);
+ socket1.write_some(null_buffers(), ec);
+
+ socket1.async_write_some(buffer(mutable_char_buffer), write_some_handler);
+ socket1.async_write_some(buffer(const_char_buffer), write_some_handler);
+ socket1.async_write_some(null_buffers(), write_some_handler);
+
+ socket1.read_some(buffer(mutable_char_buffer));
+ socket1.read_some(buffer(mutable_char_buffer), ec);
+ socket1.read_some(null_buffers(), ec);
+
+ socket1.async_read_some(buffer(mutable_char_buffer), read_some_handler);
+ socket1.async_read_some(null_buffers(), read_some_handler);
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace generic_stream_protocol_socket_compile
+
+//------------------------------------------------------------------------------
+
+BOOST_ASIO_TEST_SUITE
+(
+ "generic/stream_protocol",
+ BOOST_ASIO_TEST_CASE(generic_stream_protocol_socket_compile::test)
+)
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk