summaryrefslogtreecommitdiff
path: root/boost/asio/datagram_socket_service.hpp
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 15:11:01 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 15:11:01 +0900
commit3fdc3e5ee96dca5b11d1694975a65200787eab86 (patch)
tree5c1733853892b8397d67706fa453a9bd978d2102 /boost/asio/datagram_socket_service.hpp
parent88e602c57797660ebe0f9e15dbd64c1ff16dead3 (diff)
downloadboost-3fdc3e5ee96dca5b11d1694975a65200787eab86.tar.gz
boost-3fdc3e5ee96dca5b11d1694975a65200787eab86.tar.bz2
boost-3fdc3e5ee96dca5b11d1694975a65200787eab86.zip
Imported Upstream version 1.66.0upstream/1.66.0
Diffstat (limited to 'boost/asio/datagram_socket_service.hpp')
-rw-r--r--boost/asio/datagram_socket_service.hpp156
1 files changed, 93 insertions, 63 deletions
diff --git a/boost/asio/datagram_socket_service.hpp b/boost/asio/datagram_socket_service.hpp
index 95f179acfd..35bc2f5feb 100644
--- a/boost/asio/datagram_socket_service.hpp
+++ b/boost/asio/datagram_socket_service.hpp
@@ -16,11 +16,14 @@
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
+
+#if defined(BOOST_ASIO_ENABLE_OLD_SERVICES)
+
#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>
+#include <boost/asio/io_context.hpp>
#if defined(BOOST_ASIO_WINDOWS_RUNTIME)
# include <boost/asio/detail/null_socket_service.hpp>
@@ -39,7 +42,7 @@ namespace asio {
template <typename Protocol>
class datagram_socket_service
#if defined(GENERATING_DOCUMENTATION)
- : public boost::asio::io_service::service
+ : public boost::asio::io_context::service
#else
: public boost::asio::detail::service_base<datagram_socket_service<Protocol> >
#endif
@@ -47,7 +50,7 @@ class datagram_socket_service
public:
#if defined(GENERATING_DOCUMENTATION)
/// The unique service identifier.
- static boost::asio::io_service::id id;
+ static boost::asio::io_context::id id;
#endif
/// The protocol type.
@@ -74,13 +77,6 @@ public:
typedef typename service_impl_type::implementation_type implementation_type;
#endif
- /// (Deprecated: Use native_handle_type.) The native socket type.
-#if defined(GENERATING_DOCUMENTATION)
- typedef implementation_defined native_type;
-#else
- typedef typename service_impl_type::native_handle_type native_type;
-#endif
-
/// The native socket type.
#if defined(GENERATING_DOCUMENTATION)
typedef implementation_defined native_handle_type;
@@ -88,11 +84,11 @@ public:
typedef typename service_impl_type::native_handle_type native_handle_type;
#endif
- /// Construct a new datagram socket service for the specified io_service.
- explicit datagram_socket_service(boost::asio::io_service& io_service)
+ /// Construct a new datagram socket service for the specified io_context.
+ explicit datagram_socket_service(boost::asio::io_context& io_context)
: boost::asio::detail::service_base<
- datagram_socket_service<Protocol> >(io_service),
- service_impl_(io_service)
+ datagram_socket_service<Protocol> >(io_context),
+ service_impl_(io_context)
{
}
@@ -143,22 +139,23 @@ public:
}
// Open a new datagram socket implementation.
- boost::system::error_code open(implementation_type& impl,
+ BOOST_ASIO_SYNC_OP_VOID open(implementation_type& impl,
const protocol_type& protocol, boost::system::error_code& ec)
{
if (protocol.type() == BOOST_ASIO_OS_DEF(SOCK_DGRAM))
service_impl_.open(impl, protocol, ec);
else
ec = boost::asio::error::invalid_argument;
- return ec;
+ BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
}
/// Assign an existing native socket to a datagram socket.
- boost::system::error_code assign(implementation_type& impl,
+ BOOST_ASIO_SYNC_OP_VOID assign(implementation_type& impl,
const protocol_type& protocol, const native_handle_type& native_socket,
boost::system::error_code& ec)
{
- return service_impl_.assign(impl, protocol, native_socket, ec);
+ service_impl_.assign(impl, protocol, native_socket, ec);
+ BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
}
/// Determine whether the socket is open.
@@ -168,16 +165,18 @@ public:
}
/// Close a datagram socket implementation.
- boost::system::error_code close(implementation_type& impl,
+ BOOST_ASIO_SYNC_OP_VOID close(implementation_type& impl,
boost::system::error_code& ec)
{
- return service_impl_.close(impl, ec);
+ service_impl_.close(impl, ec);
+ BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
}
- /// (Deprecated: Use native_handle().) Get the native socket implementation.
- native_type native(implementation_type& impl)
+ /// Release ownership of the underlying socket.
+ native_handle_type release(implementation_type& impl,
+ boost::system::error_code& ec)
{
- return service_impl_.native_handle(impl);
+ return service_impl_.release(impl, ec);
}
/// Get the native socket implementation.
@@ -187,10 +186,11 @@ public:
}
/// Cancel all asynchronous operations associated with the socket.
- boost::system::error_code cancel(implementation_type& impl,
+ BOOST_ASIO_SYNC_OP_VOID cancel(implementation_type& impl,
boost::system::error_code& ec)
{
- return service_impl_.cancel(impl, ec);
+ service_impl_.cancel(impl, ec);
+ BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
}
/// Determine whether the socket is at the out-of-band data mark.
@@ -208,17 +208,19 @@ public:
}
// Bind the datagram socket to the specified local endpoint.
- boost::system::error_code bind(implementation_type& impl,
+ BOOST_ASIO_SYNC_OP_VOID bind(implementation_type& impl,
const endpoint_type& endpoint, boost::system::error_code& ec)
{
- return service_impl_.bind(impl, endpoint, ec);
+ service_impl_.bind(impl, endpoint, ec);
+ BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
}
/// Connect the datagram socket to the specified endpoint.
- boost::system::error_code connect(implementation_type& impl,
+ BOOST_ASIO_SYNC_OP_VOID connect(implementation_type& impl,
const endpoint_type& peer_endpoint, boost::system::error_code& ec)
{
- return service_impl_.connect(impl, peer_endpoint, ec);
+ service_impl_.connect(impl, peer_endpoint, ec);
+ BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
}
/// Start an asynchronous connect.
@@ -229,37 +231,39 @@ public:
const endpoint_type& peer_endpoint,
BOOST_ASIO_MOVE_ARG(ConnectHandler) handler)
{
- detail::async_result_init<
- ConnectHandler, void (boost::system::error_code)> init(
- BOOST_ASIO_MOVE_CAST(ConnectHandler)(handler));
+ async_completion<ConnectHandler,
+ void (boost::system::error_code)> init(handler);
- service_impl_.async_connect(impl, peer_endpoint, init.handler);
+ service_impl_.async_connect(impl, peer_endpoint, init.completion_handler);
return init.result.get();
}
/// Set a socket option.
template <typename SettableSocketOption>
- boost::system::error_code set_option(implementation_type& impl,
+ BOOST_ASIO_SYNC_OP_VOID set_option(implementation_type& impl,
const SettableSocketOption& option, boost::system::error_code& ec)
{
- return service_impl_.set_option(impl, option, ec);
+ service_impl_.set_option(impl, option, ec);
+ BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
}
/// Get a socket option.
template <typename GettableSocketOption>
- boost::system::error_code get_option(const implementation_type& impl,
+ BOOST_ASIO_SYNC_OP_VOID get_option(const implementation_type& impl,
GettableSocketOption& option, boost::system::error_code& ec) const
{
- return service_impl_.get_option(impl, option, ec);
+ service_impl_.get_option(impl, option, ec);
+ BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
}
/// Perform an IO control command on the socket.
template <typename IoControlCommand>
- boost::system::error_code io_control(implementation_type& impl,
+ BOOST_ASIO_SYNC_OP_VOID io_control(implementation_type& impl,
IoControlCommand& command, boost::system::error_code& ec)
{
- return service_impl_.io_control(impl, command, ec);
+ service_impl_.io_control(impl, command, ec);
+ BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
}
/// Gets the non-blocking mode of the socket.
@@ -269,10 +273,11 @@ public:
}
/// Sets the non-blocking mode of the socket.
- boost::system::error_code non_blocking(implementation_type& impl,
+ BOOST_ASIO_SYNC_OP_VOID non_blocking(implementation_type& impl,
bool mode, boost::system::error_code& ec)
{
- return service_impl_.non_blocking(impl, mode, ec);
+ service_impl_.non_blocking(impl, mode, ec);
+ BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
}
/// Gets the non-blocking mode of the native socket implementation.
@@ -282,10 +287,11 @@ public:
}
/// Sets the non-blocking mode of the native socket implementation.
- boost::system::error_code native_non_blocking(implementation_type& impl,
+ BOOST_ASIO_SYNC_OP_VOID native_non_blocking(implementation_type& impl,
bool mode, boost::system::error_code& ec)
{
- return service_impl_.native_non_blocking(impl, mode, ec);
+ service_impl_.native_non_blocking(impl, mode, ec);
+ BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
}
/// Get the local endpoint.
@@ -303,10 +309,36 @@ public:
}
/// Disable sends or receives on the socket.
- boost::system::error_code shutdown(implementation_type& impl,
+ BOOST_ASIO_SYNC_OP_VOID shutdown(implementation_type& impl,
socket_base::shutdown_type what, boost::system::error_code& ec)
{
- return service_impl_.shutdown(impl, what, ec);
+ service_impl_.shutdown(impl, what, ec);
+ BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
+ }
+
+ /// Wait for the socket to become ready to read, ready to write, or to have
+ /// pending error conditions.
+ BOOST_ASIO_SYNC_OP_VOID wait(implementation_type& impl,
+ socket_base::wait_type w, boost::system::error_code& ec)
+ {
+ service_impl_.wait(impl, w, ec);
+ BOOST_ASIO_SYNC_OP_VOID_RETURN(ec);
+ }
+
+ /// Asynchronously wait for the socket to become ready to read, ready to
+ /// write, or to have pending error conditions.
+ template <typename WaitHandler>
+ BOOST_ASIO_INITFN_RESULT_TYPE(WaitHandler,
+ void (boost::system::error_code))
+ async_wait(implementation_type& impl, socket_base::wait_type w,
+ BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
+ {
+ async_completion<WaitHandler,
+ void (boost::system::error_code)> init(handler);
+
+ service_impl_.async_wait(impl, w, init.completion_handler);
+
+ return init.result.get();
}
/// Send the given data to the peer.
@@ -326,11 +358,10 @@ public:
socket_base::message_flags flags,
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
- detail::async_result_init<
- WriteHandler, void (boost::system::error_code, std::size_t)> init(
- BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
+ async_completion<WriteHandler,
+ void (boost::system::error_code, std::size_t)> init(handler);
- service_impl_.async_send(impl, buffers, flags, init.handler);
+ service_impl_.async_send(impl, buffers, flags, init.completion_handler);
return init.result.get();
}
@@ -353,12 +384,11 @@ public:
socket_base::message_flags flags,
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
- detail::async_result_init<
- WriteHandler, void (boost::system::error_code, std::size_t)> init(
- BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
+ async_completion<WriteHandler,
+ void (boost::system::error_code, std::size_t)> init(handler);
service_impl_.async_send_to(impl, buffers,
- destination, flags, init.handler);
+ destination, flags, init.completion_handler);
return init.result.get();
}
@@ -381,11 +411,10 @@ public:
socket_base::message_flags flags,
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
{
- detail::async_result_init<
- ReadHandler, void (boost::system::error_code, std::size_t)> init(
- BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+ async_completion<ReadHandler,
+ void (boost::system::error_code, std::size_t)> init(handler);
- service_impl_.async_receive(impl, buffers, flags, init.handler);
+ service_impl_.async_receive(impl, buffers, flags, init.completion_handler);
return init.result.get();
}
@@ -409,21 +438,20 @@ public:
socket_base::message_flags flags,
BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
{
- detail::async_result_init<
- ReadHandler, void (boost::system::error_code, std::size_t)> init(
- BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+ async_completion<ReadHandler,
+ void (boost::system::error_code, std::size_t)> init(handler);
service_impl_.async_receive_from(impl, buffers,
- sender_endpoint, flags, init.handler);
+ sender_endpoint, flags, init.completion_handler);
return init.result.get();
}
private:
// Destroy all user-defined handler objects owned by the service.
- void shutdown_service()
+ void shutdown()
{
- service_impl_.shutdown_service();
+ service_impl_.shutdown();
}
// The platform-specific implementation.
@@ -435,4 +463,6 @@ private:
#include <boost/asio/detail/pop_options.hpp>
+#endif // defined(BOOST_ASIO_ENABLE_OLD_SERVICES)
+
#endif // BOOST_ASIO_DATAGRAM_SOCKET_SERVICE_HPP