mirror of
https://github.com/boostorg/asio.git
synced 2026-01-27 18:42:07 +00:00
------------------------------------------------------------------------
r84301 | chris_kohlhoff | 2013-05-17 07:34:54 +1000 (Fri, 17 May 2013) | 2 lines
Enable handler type requirements static_assert on clang.
------------------------------------------------------------------------
r84308 | chris_kohlhoff | 2013-05-17 09:26:04 +1000 (Fri, 17 May 2013) | 3 lines
Add new traits classes, handler_type and async_result, that allow
the customisation of the return type of an initiating function.
------------------------------------------------------------------------
r84311 | chris_kohlhoff | 2013-05-17 11:38:47 +1000 (Fri, 17 May 2013) | 81 lines
Add the asio::spawn() function, a high-level wrapper for running
stackful coroutines. It is based on the Boost.Coroutine library.
Here is an example of its use:
asio::spawn(my_strand, do_echo);
// ...
void do_echo(asio::yield_context yield)
{
try
{
char data[128];
for (;;)
{
std::size_t length =
my_socket.async_read_some(
asio::buffer(data), yield);
asio::async_write(my_socket,
asio::buffer(data, length), yield);
}
}
catch (std::exception& e)
{
// ...
}
}
The first argument to asio::spawn() may be a strand, io_service or
completion handler. This argument determines the context in which the
coroutine is permitted to execute. For example, a server's per-client
object may consist of multiple coroutines; they should all run on the
same strand so that no explicit synchronisation is required.
The second argument is a function object with signature (**):
void coroutine(asio::yield_context yield);
that specifies the code to be run as part of the coroutine. The
parameter yield may be passed to an asynchronous operation in place of
the completion handler, as in:
std::size_t length =
my_socket.async_read_some(
asio::buffer(data), yield);
This starts the asynchronous operation and suspends the coroutine. The
coroutine will be resumed automatically when the asynchronous operation
completes.
Where a completion handler signature has the form:
void handler(error_code ec, result_type result);
the initiating function returns the result_type. In the async_read_some
example above, this is std::size_t. If the asynchronous operation fails,
the error_code is converted into a system_error exception and thrown.
Where a completion handler signature has the form:
void handler(error_code ec);
the initiating function returns void. As above, an error is passed back
to the coroutine as a system_error exception.
To collect the error_code from an operation, rather than have it throw
an exception, associate the output variable with the yield_context as
follows:
error_code ec;
std::size_t length =
my_socket.async_read_some(
asio::buffer(data), yield[ec]);
**Note: if asio::spawn() is used with a custom completion handler of
type Handler, the function object signature is actually:
void coroutine(asio::basic_yield_context<Handler> yield);
------------------------------------------------------------------------
r84312 | chris_kohlhoff | 2013-05-17 12:25:10 +1000 (Fri, 17 May 2013) | 4 lines
Move existing examples into a C++03-specific directory, and add a new
directory for C++11-specific examples. A limited subset of the C++03
examples have been converted to their C++11 equivalents.
------------------------------------------------------------------------
r84313 | chris_kohlhoff | 2013-05-17 12:35:08 +1000 (Fri, 17 May 2013) | 26 lines
Add the asio::use_future special value, which adds first-class support
for returning a C++11 std::future from an asynchronous operation's
initiating function.
To use asio::use_future, pass it to an asynchronous operation instead of
a normal completion handler. For example:
std::future<std::size_t> length =
my_socket.async_read_some(my_buffer, asio::use_future);
Where a completion handler signature has the form:
void handler(error_code ec, result_type result);
the initiating function returns a std::future templated on result_type.
In the above example, this is std::size_t. If the asynchronous operation
fails, the error_code is converted into a system_error exception and
passed back to the caller through the future.
Where a completion handler signature has the form:
void handler(error_code ec);
the initiating function returns std::future<void>. As above, an error
is passed back in the future as a system_error exception.
------------------------------------------------------------------------
r84314 | chris_kohlhoff | 2013-05-17 13:07:51 +1000 (Fri, 17 May 2013) | 27 lines
Add a new handler hook called asio_handler_is_continuation.
Asynchronous operations may represent a continuation of the asynchronous
control flow associated with the current handler. Asio's implementation
can use this knowledge to optimise scheduling of the handler.
The asio_handler_is_continuation hook returns true to indicate whether a
completion handler represents a continuation of the current call
context. The default implementation of the hook returns false, and
applications may customise the hook when necessary. The hook has already
been customised within Asio to return true for the following cases:
- Handlers returned by strand.wrap(), when the corresponding
asynchronous operation is being initiated from within the strand.
- The internal handlers used to implement the asio::spawn() function's
stackful coroutines.
- When an intermediate handler of a composed operation (e.g.
asio::async_read(), asio::async_write(), asio::async_connect(),
ssl::stream<>, etc.) starts a new asynchronous operation due to the
composed operation not being complete.
To support this optimisation, a new running_in_this_thread() member
function has been added to the io_service::strand class. This function
returns true when called from within a strand.
------------------------------------------------------------------------
r84315 | chris_kohlhoff | 2013-05-17 20:06:50 +1000 (Fri, 17 May 2013) | 3 lines
Partially decouple Asio from other boost components via an extra level
of indirection.
------------------------------------------------------------------------
r84316 | chris_kohlhoff | 2013-05-17 20:15:21 +1000 (Fri, 17 May 2013) | 2 lines
Minor cleanup.
------------------------------------------------------------------------
r84319 | chris_kohlhoff | 2013-05-17 20:52:08 +1000 (Fri, 17 May 2013) | 9 lines
Support handshake with re-use of data already read from the wire.
Add new overloads of the SSL stream's handshake() and async_handshake()
functions, that accepts a ConstBufferSequence to be used as initial
input to the ssl engine for the handshake procedure.
Thanks go to Nick Jones <nick dot fa dot jones at gmail dot com>, on
whose work this commit is partially based.
------------------------------------------------------------------------
r84320 | chris_kohlhoff | 2013-05-17 20:57:02 +1000 (Fri, 17 May 2013) | 6 lines
Support for creation of TLSv1.1 and TLSv1.2 contexts.
Thanks go to Alvin Cheung <alvin dot cheung at alumni dot ust dot hk>
and Nick Jones <nick dot fa dot jones at gmail dot com>, on whose work
this is based.
------------------------------------------------------------------------
r84322 | chris_kohlhoff | 2013-05-17 21:00:49 +1000 (Fri, 17 May 2013) | 5 lines
Add set_verify_depth function to SSL context and stream.
Thanks go to Nick Jones <nick dot fa dot jones at gmail dot com>, on
whose work this commit is based.
------------------------------------------------------------------------
r84325 | chris_kohlhoff | 2013-05-17 21:04:11 +1000 (Fri, 17 May 2013) | 9 lines
Allow loading of SSL certificate and key data from memory buffers.
Added new buffer-based interfaces:
add_certificate_authority, use_certificate, use_certificate_chain,
use_private_key, use_rsa_private_key, use_tmp_dh.
Thanks go to Nick Jones <nick dot fa dot jones at gmail dot com>, on
whose work this commit is based.
------------------------------------------------------------------------
r84345 | chris_kohlhoff | 2013-05-18 21:24:59 +1000 (Sat, 18 May 2013) | 2 lines
Update copyright notices.
------------------------------------------------------------------------
r84346 | chris_kohlhoff | 2013-05-18 21:54:59 +1000 (Sat, 18 May 2013) | 3 lines
Remove the stackless coroutine class and macros from the HTTP server 4
example, and instead make them a part of Asio's documented interface.
------------------------------------------------------------------------
r84347 | chris_kohlhoff | 2013-05-18 22:01:59 +1000 (Sat, 18 May 2013) | 4 lines
Fix basic_waitable_timer's underlying implementation so that it can
handle any time_point value without overflowing the intermediate
duration objects.
------------------------------------------------------------------------
r84348 | chris_kohlhoff | 2013-05-18 22:07:00 +1000 (Sat, 18 May 2013) | 3 lines
Fix a problem with lost thread wakeups that can occur when making
concurrent calls to run() and poll() on the same io_service object.
------------------------------------------------------------------------
r84349 | chris_kohlhoff | 2013-05-18 22:13:17 +1000 (Sat, 18 May 2013) | 3 lines
Fix implementation of asynchronous connect operation so that it can cope
with spurious readiness notifications from the reactor.
------------------------------------------------------------------------
r84361 | chris_kohlhoff | 2013-05-19 07:56:31 +1000 (Sun, 19 May 2013) | 1 line
Remove some trailing spaces and fix another copyright notice.
------------------------------------------------------------------------
r84363 | chris_kohlhoff | 2013-05-19 14:55:11 +1000 (Sun, 19 May 2013) | 53 lines
Add generic socket protocols and converting move constructors.
Four new protocol classes have been added:
- asio::generic::datagram_protocol
- asio::generic::raw_protocol
- asio::generic::seq_packet_protocol
- asio::generic::stream_protocol
These classes implement the Protocol type requirements, but allow the
user to specify the address family (e.g. AF_INET) and protocol type
(e.g. IPPROTO_TCP) at runtime.
A new endpoint class template, asio::generic::basic_endpoint, has been
added to support these new protocol classes. This endpoint can hold any
other endpoint type, provided its native representation fits into a
sockaddr_storage object.
When using C++11, it is now possible to perform move construction from a
socket (or acceptor) object to convert to the more generic protocol's
socket (or acceptor) type. If the protocol conversion is valid:
Protocol1 p1 = ...;
Protocol2 p2(p1);
then the corresponding socket conversion is allowed:
Protocol1::socket socket1(io_service);
...
Protocol2::socket socket2(std::move(socket1));
For example, one possible conversion is from a TCP socket to a generic
stream-oriented socket:
asio::ip::tcp::socket socket1(io_service);
...
asio::generic::stream_protocol::socket socket2(std::move(socket1));
The conversion is also available for move-assignment. Note that these
conversions are not limited to the newly added generic protocol classes.
User-defined protocols may take advantage of this feature by similarly
ensuring the conversion from Protocol1 to Protocol2 is valid, as above.
As a convenience, the socket acceptor's accept() and async_accept()
functions have been changed so that they can directly accept into a
different protocol's socket type, provided the protocol conversion is
valid. For example, the following is now possible:
asio::ip::tcp::acceptor acceptor(io_service);
...
asio::generic::stream_protocol::socket socket1(io_service);
acceptor.accept(socket1);
[SVN r84388]
918 lines
28 KiB
C++
918 lines
28 KiB
C++
//
|
|
// tcp.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)
|
|
|
|
// Enable cancel() support on Windows.
|
|
#define BOOST_ASIO_ENABLE_CANCELIO 1
|
|
|
|
// Test that header file is self-contained.
|
|
#include <boost/asio/ip/tcp.hpp>
|
|
|
|
#include <cstring>
|
|
#include <boost/asio/io_service.hpp>
|
|
#include <boost/asio/read.hpp>
|
|
#include <boost/asio/write.hpp>
|
|
#include "../unit_test.hpp"
|
|
#include "../archetypes/gettable_socket_option.hpp"
|
|
#include "../archetypes/async_result.hpp"
|
|
#include "../archetypes/io_control_command.hpp"
|
|
#include "../archetypes/settable_socket_option.hpp"
|
|
|
|
#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
|
|
# include <boost/array.hpp>
|
|
#else // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
|
|
# include <array>
|
|
#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
|
|
|
|
#if defined(BOOST_ASIO_HAS_BOOST_BIND)
|
|
# include <boost/bind.hpp>
|
|
#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
|
|
# include <functional>
|
|
#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// ip_tcp_compile test
|
|
// ~~~~~~~~~~~~~~~~~~~
|
|
// The following test checks that all nested classes, enums and constants in
|
|
// ip::tcp compile and link correctly. Runtime failures are ignored.
|
|
|
|
namespace ip_tcp_compile {
|
|
|
|
void test()
|
|
{
|
|
using namespace boost::asio;
|
|
namespace ip = boost::asio::ip;
|
|
|
|
try
|
|
{
|
|
io_service ios;
|
|
ip::tcp::socket sock(ios);
|
|
|
|
// no_delay class.
|
|
|
|
ip::tcp::no_delay no_delay1(true);
|
|
sock.set_option(no_delay1);
|
|
ip::tcp::no_delay no_delay2;
|
|
sock.get_option(no_delay2);
|
|
no_delay1 = true;
|
|
(void)static_cast<bool>(no_delay1);
|
|
(void)static_cast<bool>(!no_delay1);
|
|
(void)static_cast<bool>(no_delay1.value());
|
|
}
|
|
catch (std::exception&)
|
|
{
|
|
}
|
|
}
|
|
|
|
} // namespace ip_tcp_compile
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// ip_tcp_runtime test
|
|
// ~~~~~~~~~~~~~~~~~~~
|
|
// The following test checks the runtime operation of the ip::tcp class.
|
|
|
|
namespace ip_tcp_runtime {
|
|
|
|
void test()
|
|
{
|
|
using namespace boost::asio;
|
|
namespace ip = boost::asio::ip;
|
|
|
|
io_service ios;
|
|
ip::tcp::socket sock(ios, ip::tcp::v4());
|
|
boost::system::error_code ec;
|
|
|
|
// no_delay class.
|
|
|
|
ip::tcp::no_delay no_delay1(true);
|
|
BOOST_ASIO_CHECK(no_delay1.value());
|
|
BOOST_ASIO_CHECK(static_cast<bool>(no_delay1));
|
|
BOOST_ASIO_CHECK(!!no_delay1);
|
|
sock.set_option(no_delay1, ec);
|
|
BOOST_ASIO_CHECK(!ec);
|
|
|
|
ip::tcp::no_delay no_delay2;
|
|
sock.get_option(no_delay2, ec);
|
|
BOOST_ASIO_CHECK(!ec);
|
|
BOOST_ASIO_CHECK(no_delay2.value());
|
|
BOOST_ASIO_CHECK(static_cast<bool>(no_delay2));
|
|
BOOST_ASIO_CHECK(!!no_delay2);
|
|
|
|
ip::tcp::no_delay no_delay3(false);
|
|
BOOST_ASIO_CHECK(!no_delay3.value());
|
|
BOOST_ASIO_CHECK(!static_cast<bool>(no_delay3));
|
|
BOOST_ASIO_CHECK(!no_delay3);
|
|
sock.set_option(no_delay3, ec);
|
|
BOOST_ASIO_CHECK(!ec);
|
|
|
|
ip::tcp::no_delay no_delay4;
|
|
sock.get_option(no_delay4, ec);
|
|
BOOST_ASIO_CHECK(!ec);
|
|
BOOST_ASIO_CHECK(!no_delay4.value());
|
|
BOOST_ASIO_CHECK(!static_cast<bool>(no_delay4));
|
|
BOOST_ASIO_CHECK(!no_delay4);
|
|
}
|
|
|
|
} // namespace ip_tcp_runtime
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// ip_tcp_socket_compile test
|
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// The following test checks that all public member functions on the class
|
|
// ip::tcp::socket compile and link correctly. Runtime failures are ignored.
|
|
|
|
namespace ip_tcp_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()
|
|
{
|
|
#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
|
|
using boost::array;
|
|
#else // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
|
|
using std::array;
|
|
#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
|
|
|
|
using namespace boost::asio;
|
|
namespace ip = boost::asio::ip;
|
|
|
|
try
|
|
{
|
|
io_service ios;
|
|
char mutable_char_buffer[128] = "";
|
|
const char const_char_buffer[128] = "";
|
|
array<boost::asio::mutable_buffer, 2> mutable_buffers = {{
|
|
boost::asio::buffer(mutable_char_buffer, 10),
|
|
boost::asio::buffer(mutable_char_buffer + 10, 10) }};
|
|
array<boost::asio::const_buffer, 2> const_buffers = {{
|
|
boost::asio::buffer(const_char_buffer, 10),
|
|
boost::asio::buffer(const_char_buffer + 10, 10) }};
|
|
socket_base::message_flags in_flags = 0;
|
|
archetypes::settable_socket_option<void> settable_socket_option1;
|
|
archetypes::settable_socket_option<int> settable_socket_option2;
|
|
archetypes::settable_socket_option<double> settable_socket_option3;
|
|
archetypes::gettable_socket_option<void> gettable_socket_option1;
|
|
archetypes::gettable_socket_option<int> gettable_socket_option2;
|
|
archetypes::gettable_socket_option<double> gettable_socket_option3;
|
|
archetypes::io_control_command io_control_command;
|
|
archetypes::lazy_handler lazy;
|
|
boost::system::error_code ec;
|
|
|
|
// basic_stream_socket constructors.
|
|
|
|
ip::tcp::socket socket1(ios);
|
|
ip::tcp::socket socket2(ios, ip::tcp::v4());
|
|
ip::tcp::socket socket3(ios, ip::tcp::v6());
|
|
ip::tcp::socket socket4(ios, ip::tcp::endpoint(ip::tcp::v4(), 0));
|
|
ip::tcp::socket socket5(ios, ip::tcp::endpoint(ip::tcp::v6(), 0));
|
|
int native_socket1 = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
|
ip::tcp::socket socket6(ios, ip::tcp::v4(), native_socket1);
|
|
|
|
#if defined(BOOST_ASIO_HAS_MOVE)
|
|
ip::tcp::socket socket7(std::move(socket6));
|
|
#endif // defined(BOOST_ASIO_HAS_MOVE)
|
|
|
|
// basic_stream_socket operators.
|
|
|
|
#if defined(BOOST_ASIO_HAS_MOVE)
|
|
socket1 = ip::tcp::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.
|
|
|
|
ip::tcp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer();
|
|
(void)lowest_layer;
|
|
|
|
const ip::tcp::socket& socket8 = socket1;
|
|
const ip::tcp::socket::lowest_layer_type& lowest_layer2
|
|
= socket8.lowest_layer();
|
|
(void)lowest_layer2;
|
|
|
|
socket1.open(ip::tcp::v4());
|
|
socket1.open(ip::tcp::v6());
|
|
socket1.open(ip::tcp::v4(), ec);
|
|
socket1.open(ip::tcp::v6(), ec);
|
|
|
|
int native_socket2 = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
|
socket1.assign(ip::tcp::v4(), native_socket2);
|
|
int native_socket3 = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
|
socket1.assign(ip::tcp::v4(), native_socket3, ec);
|
|
|
|
bool is_open = socket1.is_open();
|
|
(void)is_open;
|
|
|
|
socket1.close();
|
|
socket1.close(ec);
|
|
|
|
ip::tcp::socket::native_type native_socket4 = socket1.native();
|
|
(void)native_socket4;
|
|
|
|
ip::tcp::socket::native_handle_type native_socket5
|
|
= socket1.native_handle();
|
|
(void)native_socket5;
|
|
|
|
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(ip::tcp::endpoint(ip::tcp::v4(), 0));
|
|
socket1.bind(ip::tcp::endpoint(ip::tcp::v6(), 0));
|
|
socket1.bind(ip::tcp::endpoint(ip::tcp::v4(), 0), ec);
|
|
socket1.bind(ip::tcp::endpoint(ip::tcp::v6(), 0), ec);
|
|
|
|
socket1.connect(ip::tcp::endpoint(ip::tcp::v4(), 0));
|
|
socket1.connect(ip::tcp::endpoint(ip::tcp::v6(), 0));
|
|
socket1.connect(ip::tcp::endpoint(ip::tcp::v4(), 0), ec);
|
|
socket1.connect(ip::tcp::endpoint(ip::tcp::v6(), 0), ec);
|
|
|
|
socket1.async_connect(ip::tcp::endpoint(ip::tcp::v4(), 0),
|
|
&connect_handler);
|
|
socket1.async_connect(ip::tcp::endpoint(ip::tcp::v6(), 0),
|
|
&connect_handler);
|
|
int i1 = socket1.async_connect(ip::tcp::endpoint(ip::tcp::v4(), 0), lazy);
|
|
(void)i1;
|
|
int i2 = socket1.async_connect(ip::tcp::endpoint(ip::tcp::v6(), 0), lazy);
|
|
(void)i2;
|
|
|
|
socket1.set_option(settable_socket_option1);
|
|
socket1.set_option(settable_socket_option1, ec);
|
|
socket1.set_option(settable_socket_option2);
|
|
socket1.set_option(settable_socket_option2, ec);
|
|
socket1.set_option(settable_socket_option3);
|
|
socket1.set_option(settable_socket_option3, ec);
|
|
|
|
socket1.get_option(gettable_socket_option1);
|
|
socket1.get_option(gettable_socket_option1, ec);
|
|
socket1.get_option(gettable_socket_option2);
|
|
socket1.get_option(gettable_socket_option2, ec);
|
|
socket1.get_option(gettable_socket_option3);
|
|
socket1.get_option(gettable_socket_option3, ec);
|
|
|
|
socket1.io_control(io_control_command);
|
|
socket1.io_control(io_control_command, ec);
|
|
|
|
bool non_blocking1 = socket1.non_blocking();
|
|
(void)non_blocking1;
|
|
socket1.non_blocking(true);
|
|
socket1.non_blocking(false, ec);
|
|
|
|
bool non_blocking2 = socket1.native_non_blocking();
|
|
(void)non_blocking2;
|
|
socket1.native_non_blocking(true);
|
|
socket1.native_non_blocking(false, ec);
|
|
|
|
ip::tcp::endpoint endpoint1 = socket1.local_endpoint();
|
|
ip::tcp::endpoint endpoint2 = socket1.local_endpoint(ec);
|
|
|
|
ip::tcp::endpoint endpoint3 = socket1.remote_endpoint();
|
|
ip::tcp::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(mutable_buffers);
|
|
socket1.send(const_buffers);
|
|
socket1.send(null_buffers());
|
|
socket1.send(buffer(mutable_char_buffer), in_flags);
|
|
socket1.send(buffer(const_char_buffer), in_flags);
|
|
socket1.send(mutable_buffers, in_flags);
|
|
socket1.send(const_buffers, 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(mutable_buffers, in_flags, ec);
|
|
socket1.send(const_buffers, 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(mutable_buffers, &send_handler);
|
|
socket1.async_send(const_buffers, &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(mutable_buffers, in_flags, &send_handler);
|
|
socket1.async_send(const_buffers, in_flags, &send_handler);
|
|
socket1.async_send(null_buffers(), in_flags, &send_handler);
|
|
int i3 = socket1.async_send(buffer(mutable_char_buffer), lazy);
|
|
(void)i3;
|
|
int i4 = socket1.async_send(buffer(const_char_buffer), lazy);
|
|
(void)i4;
|
|
int i5 = socket1.async_send(mutable_buffers, lazy);
|
|
(void)i5;
|
|
int i6 = socket1.async_send(const_buffers, lazy);
|
|
(void)i6;
|
|
int i7 = socket1.async_send(null_buffers(), lazy);
|
|
(void)i7;
|
|
int i8 = socket1.async_send(buffer(mutable_char_buffer), in_flags, lazy);
|
|
(void)i8;
|
|
int i9 = socket1.async_send(buffer(const_char_buffer), in_flags, lazy);
|
|
(void)i9;
|
|
int i10 = socket1.async_send(mutable_buffers, in_flags, lazy);
|
|
(void)i10;
|
|
int i11 = socket1.async_send(const_buffers, in_flags, lazy);
|
|
(void)i11;
|
|
int i12 = socket1.async_send(null_buffers(), in_flags, lazy);
|
|
(void)i12;
|
|
|
|
socket1.receive(buffer(mutable_char_buffer));
|
|
socket1.receive(mutable_buffers);
|
|
socket1.receive(null_buffers());
|
|
socket1.receive(buffer(mutable_char_buffer), in_flags);
|
|
socket1.receive(mutable_buffers, in_flags);
|
|
socket1.receive(null_buffers(), in_flags);
|
|
socket1.receive(buffer(mutable_char_buffer), in_flags, ec);
|
|
socket1.receive(mutable_buffers, in_flags, ec);
|
|
socket1.receive(null_buffers(), in_flags, ec);
|
|
|
|
socket1.async_receive(buffer(mutable_char_buffer), &receive_handler);
|
|
socket1.async_receive(mutable_buffers, &receive_handler);
|
|
socket1.async_receive(null_buffers(), &receive_handler);
|
|
socket1.async_receive(buffer(mutable_char_buffer), in_flags,
|
|
&receive_handler);
|
|
socket1.async_receive(mutable_buffers, in_flags, &receive_handler);
|
|
socket1.async_receive(null_buffers(), in_flags, &receive_handler);
|
|
int i13 = socket1.async_receive(buffer(mutable_char_buffer), lazy);
|
|
(void)i13;
|
|
int i14 = socket1.async_receive(mutable_buffers, lazy);
|
|
(void)i14;
|
|
int i15 = socket1.async_receive(null_buffers(), lazy);
|
|
(void)i15;
|
|
int i16 = socket1.async_receive(buffer(mutable_char_buffer), in_flags,
|
|
lazy);
|
|
(void)i16;
|
|
int i17 = socket1.async_receive(mutable_buffers, in_flags, lazy);
|
|
(void)i17;
|
|
int i18 = socket1.async_receive(null_buffers(), in_flags, lazy);
|
|
(void)i18;
|
|
|
|
socket1.write_some(buffer(mutable_char_buffer));
|
|
socket1.write_some(buffer(const_char_buffer));
|
|
socket1.write_some(mutable_buffers);
|
|
socket1.write_some(const_buffers);
|
|
socket1.write_some(null_buffers());
|
|
socket1.write_some(buffer(mutable_char_buffer), ec);
|
|
socket1.write_some(buffer(const_char_buffer), ec);
|
|
socket1.write_some(mutable_buffers, ec);
|
|
socket1.write_some(const_buffers, 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(mutable_buffers, &write_some_handler);
|
|
socket1.async_write_some(const_buffers, &write_some_handler);
|
|
socket1.async_write_some(null_buffers(), &write_some_handler);
|
|
int i19 = socket1.async_write_some(buffer(mutable_char_buffer), lazy);
|
|
(void)i19;
|
|
int i20 = socket1.async_write_some(buffer(const_char_buffer), lazy);
|
|
(void)i20;
|
|
int i21 = socket1.async_write_some(mutable_buffers, lazy);
|
|
(void)i21;
|
|
int i22 = socket1.async_write_some(const_buffers, lazy);
|
|
(void)i22;
|
|
int i23 = socket1.async_write_some(null_buffers(), lazy);
|
|
(void)i23;
|
|
|
|
socket1.read_some(buffer(mutable_char_buffer));
|
|
socket1.read_some(mutable_buffers);
|
|
socket1.read_some(null_buffers());
|
|
socket1.read_some(buffer(mutable_char_buffer), ec);
|
|
socket1.read_some(mutable_buffers, ec);
|
|
socket1.read_some(null_buffers(), ec);
|
|
|
|
socket1.async_read_some(buffer(mutable_char_buffer), &read_some_handler);
|
|
socket1.async_read_some(mutable_buffers, &read_some_handler);
|
|
socket1.async_read_some(null_buffers(), &read_some_handler);
|
|
int i24 = socket1.async_read_some(buffer(mutable_char_buffer), lazy);
|
|
(void)i24;
|
|
int i25 = socket1.async_read_some(mutable_buffers, lazy);
|
|
(void)i25;
|
|
int i26 = socket1.async_read_some(null_buffers(), lazy);
|
|
(void)i26;
|
|
}
|
|
catch (std::exception&)
|
|
{
|
|
}
|
|
}
|
|
|
|
} // namespace ip_tcp_socket_compile
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// ip_tcp_socket_runtime test
|
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// The following test checks the runtime operation of the ip::tcp::socket class.
|
|
|
|
namespace ip_tcp_socket_runtime {
|
|
|
|
static const char write_data[]
|
|
= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
|
|
void handle_read_noop(const boost::system::error_code& err,
|
|
size_t bytes_transferred, bool* called)
|
|
{
|
|
*called = true;
|
|
BOOST_ASIO_CHECK(!err);
|
|
BOOST_ASIO_CHECK(bytes_transferred == 0);
|
|
}
|
|
|
|
void handle_write_noop(const boost::system::error_code& err,
|
|
size_t bytes_transferred, bool* called)
|
|
{
|
|
*called = true;
|
|
BOOST_ASIO_CHECK(!err);
|
|
BOOST_ASIO_CHECK(bytes_transferred == 0);
|
|
}
|
|
|
|
void handle_read(const boost::system::error_code& err,
|
|
size_t bytes_transferred, bool* called)
|
|
{
|
|
*called = true;
|
|
BOOST_ASIO_CHECK(!err);
|
|
BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
|
|
}
|
|
|
|
void handle_write(const boost::system::error_code& err,
|
|
size_t bytes_transferred, bool* called)
|
|
{
|
|
*called = true;
|
|
BOOST_ASIO_CHECK(!err);
|
|
BOOST_ASIO_CHECK(bytes_transferred == sizeof(write_data));
|
|
}
|
|
|
|
void handle_read_cancel(const boost::system::error_code& err,
|
|
size_t bytes_transferred, bool* called)
|
|
{
|
|
*called = true;
|
|
BOOST_ASIO_CHECK(err == boost::asio::error::operation_aborted);
|
|
BOOST_ASIO_CHECK(bytes_transferred == 0);
|
|
}
|
|
|
|
void handle_read_eof(const boost::system::error_code& err,
|
|
size_t bytes_transferred, bool* called)
|
|
{
|
|
*called = true;
|
|
BOOST_ASIO_CHECK(err == boost::asio::error::eof);
|
|
BOOST_ASIO_CHECK(bytes_transferred == 0);
|
|
}
|
|
|
|
void test()
|
|
{
|
|
using namespace std; // For memcmp.
|
|
using namespace boost::asio;
|
|
namespace ip = boost::asio::ip;
|
|
|
|
#if defined(BOOST_ASIO_HAS_BOOST_BIND)
|
|
namespace bindns = boost;
|
|
#else // defined(BOOST_ASIO_HAS_BOOST_BIND)
|
|
namespace bindns = std;
|
|
using std::placeholders::_1;
|
|
using std::placeholders::_2;
|
|
#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
|
|
|
|
io_service ios;
|
|
|
|
ip::tcp::acceptor acceptor(ios, ip::tcp::endpoint(ip::tcp::v4(), 0));
|
|
ip::tcp::endpoint server_endpoint = acceptor.local_endpoint();
|
|
server_endpoint.address(ip::address_v4::loopback());
|
|
|
|
ip::tcp::socket client_side_socket(ios);
|
|
ip::tcp::socket server_side_socket(ios);
|
|
|
|
client_side_socket.connect(server_endpoint);
|
|
acceptor.accept(server_side_socket);
|
|
|
|
// No-op read.
|
|
|
|
bool read_noop_completed = false;
|
|
client_side_socket.async_read_some(
|
|
boost::asio::mutable_buffers_1(0, 0),
|
|
bindns::bind(handle_read_noop,
|
|
_1, _2, &read_noop_completed));
|
|
|
|
ios.run();
|
|
BOOST_ASIO_CHECK(read_noop_completed);
|
|
|
|
// No-op write.
|
|
|
|
bool write_noop_completed = false;
|
|
client_side_socket.async_write_some(
|
|
boost::asio::const_buffers_1(0, 0),
|
|
bindns::bind(handle_write_noop,
|
|
_1, _2, &write_noop_completed));
|
|
|
|
ios.reset();
|
|
ios.run();
|
|
BOOST_ASIO_CHECK(write_noop_completed);
|
|
|
|
// Read and write to transfer data.
|
|
|
|
char read_buffer[sizeof(write_data)];
|
|
bool read_completed = false;
|
|
boost::asio::async_read(client_side_socket,
|
|
boost::asio::buffer(read_buffer),
|
|
bindns::bind(handle_read,
|
|
_1, _2, &read_completed));
|
|
|
|
bool write_completed = false;
|
|
boost::asio::async_write(server_side_socket,
|
|
boost::asio::buffer(write_data),
|
|
bindns::bind(handle_write,
|
|
_1, _2, &write_completed));
|
|
|
|
ios.reset();
|
|
ios.run();
|
|
BOOST_ASIO_CHECK(read_completed);
|
|
BOOST_ASIO_CHECK(write_completed);
|
|
BOOST_ASIO_CHECK(memcmp(read_buffer, write_data, sizeof(write_data)) == 0);
|
|
|
|
// Cancelled read.
|
|
|
|
bool read_cancel_completed = false;
|
|
boost::asio::async_read(server_side_socket,
|
|
boost::asio::buffer(read_buffer),
|
|
bindns::bind(handle_read_cancel,
|
|
_1, _2, &read_cancel_completed));
|
|
|
|
ios.reset();
|
|
ios.poll();
|
|
BOOST_ASIO_CHECK(!read_cancel_completed);
|
|
|
|
server_side_socket.cancel();
|
|
|
|
ios.reset();
|
|
ios.run();
|
|
BOOST_ASIO_CHECK(read_cancel_completed);
|
|
|
|
// A read when the peer closes socket should fail with eof.
|
|
|
|
bool read_eof_completed = false;
|
|
boost::asio::async_read(client_side_socket,
|
|
boost::asio::buffer(read_buffer),
|
|
bindns::bind(handle_read_eof,
|
|
_1, _2, &read_eof_completed));
|
|
|
|
server_side_socket.close();
|
|
|
|
ios.reset();
|
|
ios.run();
|
|
BOOST_ASIO_CHECK(read_eof_completed);
|
|
}
|
|
|
|
} // namespace ip_tcp_socket_runtime
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// ip_tcp_acceptor_compile test
|
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// The following test checks that all public member functions on the class
|
|
// ip::tcp::acceptor compile and link correctly. Runtime failures are ignored.
|
|
|
|
namespace ip_tcp_acceptor_compile {
|
|
|
|
void accept_handler(const boost::system::error_code&)
|
|
{
|
|
}
|
|
|
|
void test()
|
|
{
|
|
using namespace boost::asio;
|
|
namespace ip = boost::asio::ip;
|
|
|
|
try
|
|
{
|
|
io_service ios;
|
|
ip::tcp::socket peer_socket(ios);
|
|
ip::tcp::endpoint peer_endpoint;
|
|
archetypes::settable_socket_option<void> settable_socket_option1;
|
|
archetypes::settable_socket_option<int> settable_socket_option2;
|
|
archetypes::settable_socket_option<double> settable_socket_option3;
|
|
archetypes::gettable_socket_option<void> gettable_socket_option1;
|
|
archetypes::gettable_socket_option<int> gettable_socket_option2;
|
|
archetypes::gettable_socket_option<double> gettable_socket_option3;
|
|
archetypes::io_control_command io_control_command;
|
|
archetypes::lazy_handler lazy;
|
|
boost::system::error_code ec;
|
|
|
|
// basic_socket_acceptor constructors.
|
|
|
|
ip::tcp::acceptor acceptor1(ios);
|
|
ip::tcp::acceptor acceptor2(ios, ip::tcp::v4());
|
|
ip::tcp::acceptor acceptor3(ios, ip::tcp::v6());
|
|
ip::tcp::acceptor acceptor4(ios, ip::tcp::endpoint(ip::tcp::v4(), 0));
|
|
ip::tcp::acceptor acceptor5(ios, ip::tcp::endpoint(ip::tcp::v6(), 0));
|
|
int native_acceptor1 = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
|
ip::tcp::acceptor acceptor6(ios, ip::tcp::v4(), native_acceptor1);
|
|
|
|
#if defined(BOOST_ASIO_HAS_MOVE)
|
|
ip::tcp::acceptor acceptor7(std::move(acceptor6));
|
|
#endif // defined(BOOST_ASIO_HAS_MOVE)
|
|
|
|
// basic_socket_acceptor operators.
|
|
|
|
#if defined(BOOST_ASIO_HAS_MOVE)
|
|
acceptor1 = ip::tcp::acceptor(ios);
|
|
acceptor1 = std::move(acceptor2);
|
|
#endif // defined(BOOST_ASIO_HAS_MOVE)
|
|
|
|
// basic_io_object functions.
|
|
|
|
io_service& ios_ref = acceptor1.get_io_service();
|
|
(void)ios_ref;
|
|
|
|
// basic_socket_acceptor functions.
|
|
|
|
acceptor1.open(ip::tcp::v4());
|
|
acceptor1.open(ip::tcp::v6());
|
|
acceptor1.open(ip::tcp::v4(), ec);
|
|
acceptor1.open(ip::tcp::v6(), ec);
|
|
|
|
int native_acceptor2 = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
|
acceptor1.assign(ip::tcp::v4(), native_acceptor2);
|
|
int native_acceptor3 = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
|
acceptor1.assign(ip::tcp::v4(), native_acceptor3, ec);
|
|
|
|
bool is_open = acceptor1.is_open();
|
|
(void)is_open;
|
|
|
|
acceptor1.close();
|
|
acceptor1.close(ec);
|
|
|
|
ip::tcp::acceptor::native_type native_acceptor4 = acceptor1.native();
|
|
(void)native_acceptor4;
|
|
|
|
ip::tcp::acceptor::native_handle_type native_acceptor5
|
|
= acceptor1.native_handle();
|
|
(void)native_acceptor5;
|
|
|
|
acceptor1.cancel();
|
|
acceptor1.cancel(ec);
|
|
|
|
acceptor1.bind(ip::tcp::endpoint(ip::tcp::v4(), 0));
|
|
acceptor1.bind(ip::tcp::endpoint(ip::tcp::v6(), 0));
|
|
acceptor1.bind(ip::tcp::endpoint(ip::tcp::v4(), 0), ec);
|
|
acceptor1.bind(ip::tcp::endpoint(ip::tcp::v6(), 0), ec);
|
|
|
|
acceptor1.set_option(settable_socket_option1);
|
|
acceptor1.set_option(settable_socket_option1, ec);
|
|
acceptor1.set_option(settable_socket_option2);
|
|
acceptor1.set_option(settable_socket_option2, ec);
|
|
acceptor1.set_option(settable_socket_option3);
|
|
acceptor1.set_option(settable_socket_option3, ec);
|
|
|
|
acceptor1.get_option(gettable_socket_option1);
|
|
acceptor1.get_option(gettable_socket_option1, ec);
|
|
acceptor1.get_option(gettable_socket_option2);
|
|
acceptor1.get_option(gettable_socket_option2, ec);
|
|
acceptor1.get_option(gettable_socket_option3);
|
|
acceptor1.get_option(gettable_socket_option3, ec);
|
|
|
|
acceptor1.io_control(io_control_command);
|
|
acceptor1.io_control(io_control_command, ec);
|
|
|
|
bool non_blocking1 = acceptor1.non_blocking();
|
|
(void)non_blocking1;
|
|
acceptor1.non_blocking(true);
|
|
acceptor1.non_blocking(false, ec);
|
|
|
|
bool non_blocking2 = acceptor1.native_non_blocking();
|
|
(void)non_blocking2;
|
|
acceptor1.native_non_blocking(true);
|
|
acceptor1.native_non_blocking(false, ec);
|
|
|
|
ip::tcp::endpoint endpoint1 = acceptor1.local_endpoint();
|
|
ip::tcp::endpoint endpoint2 = acceptor1.local_endpoint(ec);
|
|
|
|
acceptor1.accept(peer_socket);
|
|
acceptor1.accept(peer_socket, ec);
|
|
acceptor1.accept(peer_socket, peer_endpoint);
|
|
acceptor1.accept(peer_socket, peer_endpoint, ec);
|
|
|
|
acceptor1.async_accept(peer_socket, &accept_handler);
|
|
acceptor1.async_accept(peer_socket, peer_endpoint, &accept_handler);
|
|
int i1 = acceptor1.async_accept(peer_socket, lazy);
|
|
(void)i1;
|
|
int i2 = acceptor1.async_accept(peer_socket, peer_endpoint, lazy);
|
|
(void)i2;
|
|
}
|
|
catch (std::exception&)
|
|
{
|
|
}
|
|
}
|
|
|
|
} // namespace ip_tcp_acceptor_compile
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// ip_tcp_acceptor_runtime test
|
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// The following test checks the runtime operation of the ip::tcp::acceptor
|
|
// class.
|
|
|
|
namespace ip_tcp_acceptor_runtime {
|
|
|
|
void handle_accept(const boost::system::error_code& err)
|
|
{
|
|
BOOST_ASIO_CHECK(!err);
|
|
}
|
|
|
|
void handle_connect(const boost::system::error_code& err)
|
|
{
|
|
BOOST_ASIO_CHECK(!err);
|
|
}
|
|
|
|
void test()
|
|
{
|
|
using namespace boost::asio;
|
|
namespace ip = boost::asio::ip;
|
|
|
|
io_service ios;
|
|
|
|
ip::tcp::acceptor acceptor(ios, ip::tcp::endpoint(ip::tcp::v4(), 0));
|
|
ip::tcp::endpoint server_endpoint = acceptor.local_endpoint();
|
|
server_endpoint.address(ip::address_v4::loopback());
|
|
|
|
ip::tcp::socket client_side_socket(ios);
|
|
ip::tcp::socket server_side_socket(ios);
|
|
|
|
client_side_socket.connect(server_endpoint);
|
|
acceptor.accept(server_side_socket);
|
|
|
|
client_side_socket.close();
|
|
server_side_socket.close();
|
|
|
|
client_side_socket.connect(server_endpoint);
|
|
ip::tcp::endpoint client_endpoint;
|
|
acceptor.accept(server_side_socket, client_endpoint);
|
|
|
|
ip::tcp::acceptor::non_blocking_io command(false);
|
|
acceptor.io_control(command);
|
|
|
|
ip::tcp::endpoint client_side_local_endpoint
|
|
= client_side_socket.local_endpoint();
|
|
BOOST_ASIO_CHECK(client_side_local_endpoint.port() == client_endpoint.port());
|
|
|
|
ip::tcp::endpoint server_side_remote_endpoint
|
|
= server_side_socket.remote_endpoint();
|
|
BOOST_ASIO_CHECK(server_side_remote_endpoint.port()
|
|
== client_endpoint.port());
|
|
|
|
client_side_socket.close();
|
|
server_side_socket.close();
|
|
|
|
acceptor.async_accept(server_side_socket, &handle_accept);
|
|
client_side_socket.async_connect(server_endpoint, &handle_connect);
|
|
|
|
ios.run();
|
|
|
|
client_side_socket.close();
|
|
server_side_socket.close();
|
|
|
|
acceptor.async_accept(server_side_socket, client_endpoint, &handle_accept);
|
|
client_side_socket.async_connect(server_endpoint, &handle_connect);
|
|
|
|
ios.reset();
|
|
ios.run();
|
|
|
|
client_side_local_endpoint = client_side_socket.local_endpoint();
|
|
BOOST_ASIO_CHECK(client_side_local_endpoint.port() == client_endpoint.port());
|
|
|
|
server_side_remote_endpoint = server_side_socket.remote_endpoint();
|
|
BOOST_ASIO_CHECK(server_side_remote_endpoint.port()
|
|
== client_endpoint.port());
|
|
}
|
|
|
|
} // namespace ip_tcp_acceptor_runtime
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// ip_tcp_resolver_compile test
|
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// The following test checks that all public member functions on the class
|
|
// ip::tcp::resolver compile and link correctly. Runtime failures are ignored.
|
|
|
|
namespace ip_tcp_resolver_compile {
|
|
|
|
void resolve_handler(const boost::system::error_code&,
|
|
boost::asio::ip::tcp::resolver::iterator)
|
|
{
|
|
}
|
|
|
|
void test()
|
|
{
|
|
using namespace boost::asio;
|
|
namespace ip = boost::asio::ip;
|
|
|
|
try
|
|
{
|
|
io_service ios;
|
|
archetypes::lazy_handler lazy;
|
|
boost::system::error_code ec;
|
|
ip::tcp::resolver::query q(ip::tcp::v4(), "localhost", "0");
|
|
ip::tcp::endpoint e(ip::address_v4::loopback(), 0);
|
|
|
|
// basic_resolver constructors.
|
|
|
|
ip::tcp::resolver resolver(ios);
|
|
|
|
// basic_io_object functions.
|
|
|
|
io_service& ios_ref = resolver.get_io_service();
|
|
(void)ios_ref;
|
|
|
|
// basic_resolver functions.
|
|
|
|
resolver.cancel();
|
|
|
|
ip::tcp::resolver::iterator iter1 = resolver.resolve(q);
|
|
(void)iter1;
|
|
|
|
ip::tcp::resolver::iterator iter2 = resolver.resolve(q, ec);
|
|
(void)iter2;
|
|
|
|
ip::tcp::resolver::iterator iter3 = resolver.resolve(e);
|
|
(void)iter3;
|
|
|
|
ip::tcp::resolver::iterator iter4 = resolver.resolve(e, ec);
|
|
(void)iter4;
|
|
|
|
resolver.async_resolve(q, &resolve_handler);
|
|
int i1 = resolver.async_resolve(q, lazy);
|
|
(void)i1;
|
|
|
|
resolver.async_resolve(e, &resolve_handler);
|
|
int i2 = resolver.async_resolve(e, lazy);
|
|
(void)i2;
|
|
}
|
|
catch (std::exception&)
|
|
{
|
|
}
|
|
}
|
|
|
|
} // namespace ip_tcp_resolver_compile
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
BOOST_ASIO_TEST_SUITE
|
|
(
|
|
"ip/tcp",
|
|
BOOST_ASIO_TEST_CASE(ip_tcp_compile::test)
|
|
BOOST_ASIO_TEST_CASE(ip_tcp_runtime::test)
|
|
BOOST_ASIO_TEST_CASE(ip_tcp_socket_compile::test)
|
|
BOOST_ASIO_TEST_CASE(ip_tcp_socket_runtime::test)
|
|
BOOST_ASIO_TEST_CASE(ip_tcp_acceptor_compile::test)
|
|
BOOST_ASIO_TEST_CASE(ip_tcp_acceptor_runtime::test)
|
|
BOOST_ASIO_TEST_CASE(ip_tcp_resolver_compile::test)
|
|
)
|