mirror of
https://github.com/boostorg/beast.git
synced 2025-08-03 14:54:32 +02:00
basic_stream connects are members
This commit is contained in:
@@ -64,12 +64,10 @@
|
||||
<bridgehead renderas="sect3">Functions</bridgehead>
|
||||
<simplelist type="vert" columns="1">
|
||||
<member><link linkend="beast.ref.boost__beast__allocate_stable">allocate_stable</link> <emphasis role="green">🞲</emphasis></member>
|
||||
<member><link linkend="beast.ref.boost__beast__async_connect">async_connect</link> <emphasis role="green">🞲</emphasis></member>
|
||||
<member><link linkend="beast.ref.boost__beast__beast_close_socket">beast_close_socket</link> <emphasis role="green">🞲</emphasis></member>
|
||||
<member><link linkend="beast.ref.boost__beast__bind_front_handler">bind_front_handler</link> <emphasis role="green">🞲</emphasis></member>
|
||||
<member><link linkend="beast.ref.boost__beast__bind_handler">bind_handler</link></member>
|
||||
<member><link linkend="beast.ref.boost__beast__close_socket">close_socket</link> <emphasis role="green">🞲</emphasis></member>
|
||||
<member><link linkend="beast.ref.boost__beast__connect">connect</link> <emphasis role="green">🞲</emphasis></member>
|
||||
<member><link linkend="beast.ref.boost__beast__generic_category">generic_category</link></member>
|
||||
<member><link linkend="beast.ref.boost__beast__get_lowest_layer">get_lowest_layer</link> <emphasis role="green">🞲</emphasis></member>
|
||||
<member><link linkend="beast.ref.boost__beast__iequals">iequals</link></member>
|
||||
|
@@ -103,8 +103,7 @@ public:
|
||||
beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30));
|
||||
|
||||
// Make the connection on the IP address we get from a lookup
|
||||
beast::async_connect(
|
||||
beast::get_lowest_layer(stream_),
|
||||
beast::get_lowest_layer(stream_).async_connect(
|
||||
results,
|
||||
beast::bind_front_handler(
|
||||
&session::on_connect,
|
||||
|
@@ -91,8 +91,7 @@ public:
|
||||
stream_.expires_after(std::chrono::seconds(30));
|
||||
|
||||
// Make the connection on the IP address we get from a lookup
|
||||
beast::async_connect(
|
||||
stream_,
|
||||
stream_.async_connect(
|
||||
results,
|
||||
beast::bind_front_handler(
|
||||
&session::on_connect,
|
||||
|
@@ -74,7 +74,7 @@ do_session(
|
||||
beast::get_lowest_layer(stream).expires_after(std::chrono::seconds(30));
|
||||
|
||||
// Make the connection on the IP address we get from a lookup
|
||||
beast::async_connect(get_lowest_layer(stream), results, yield[ec]);
|
||||
get_lowest_layer(stream).async_connect(results, yield[ec]);
|
||||
if(ec)
|
||||
return fail(ec, "connect");
|
||||
|
||||
|
@@ -61,7 +61,7 @@ do_session(
|
||||
stream.expires_after(std::chrono::seconds(30));
|
||||
|
||||
// Make the connection on the IP address we get from a lookup
|
||||
beast::async_connect(stream, results, yield[ec]);
|
||||
stream.async_connect(results, yield[ec]);
|
||||
if(ec)
|
||||
return fail(ec, "connect");
|
||||
|
||||
|
@@ -223,8 +223,7 @@ public:
|
||||
stream_.expires_after(std::chrono::seconds(10));
|
||||
|
||||
// Make the connection on the IP address we get from a lookup
|
||||
beast::async_connect(
|
||||
stream_,
|
||||
stream_.async_connect(
|
||||
results,
|
||||
beast::bind_front_handler(
|
||||
&worker::on_connect,
|
||||
|
@@ -80,7 +80,7 @@ int main(int argc, char** argv)
|
||||
auto const results = resolver.resolve(host, port);
|
||||
|
||||
// Make the connection on the IP address we get from a lookup
|
||||
beast::connect(beast::get_lowest_layer(stream), results);
|
||||
beast::get_lowest_layer(stream).connect(results);
|
||||
|
||||
// Perform the SSL handshake
|
||||
stream.handshake(ssl::stream_base::client);
|
||||
|
@@ -60,7 +60,7 @@ int main(int argc, char** argv)
|
||||
auto const results = resolver.resolve(host, port);
|
||||
|
||||
// Make the connection on the IP address we get from a lookup
|
||||
beast::connect(stream, results);
|
||||
stream.connect(results);
|
||||
|
||||
// Set up an HTTP GET request message
|
||||
http::request<http::string_body> req{http::verb::get, target, version};
|
||||
|
@@ -92,8 +92,7 @@ public:
|
||||
beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30));
|
||||
|
||||
// Make the connection on the IP address we get from a lookup
|
||||
beast::async_connect(
|
||||
beast::get_lowest_layer(ws_),
|
||||
beast::get_lowest_layer(ws_).async_connect(
|
||||
results,
|
||||
beast::bind_front_handler(
|
||||
&session::on_connect,
|
||||
|
@@ -86,8 +86,7 @@ public:
|
||||
beast::get_lowest_layer(ws_).expires_after(std::chrono::seconds(30));
|
||||
|
||||
// Make the connection on the IP address we get from a lookup
|
||||
beast::async_connect(
|
||||
beast::get_lowest_layer(ws_),
|
||||
beast::get_lowest_layer(ws_).async_connect(
|
||||
results,
|
||||
beast::bind_front_handler(
|
||||
&session::on_connect,
|
||||
|
@@ -67,7 +67,7 @@ do_session(
|
||||
beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30));
|
||||
|
||||
// Make the connection on the IP address we get from a lookup
|
||||
beast::async_connect(beast::get_lowest_layer(ws), results, yield[ec]);
|
||||
beast::get_lowest_layer(ws).async_connect(results, yield[ec]);
|
||||
if(ec)
|
||||
return fail(ec, "connect");
|
||||
|
||||
|
@@ -60,7 +60,7 @@ do_session(
|
||||
beast::get_lowest_layer(ws).expires_after(std::chrono::seconds(30));
|
||||
|
||||
// Make the connection on the IP address we get from a lookup
|
||||
beast::async_connect(ws.next_layer(), results, yield[ec]);
|
||||
beast::get_lowest_layer(ws).async_connect(results, yield[ec]);
|
||||
if(ec)
|
||||
return fail(ec, "connect");
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -21,9 +21,6 @@ namespace boost {
|
||||
namespace beast {
|
||||
namespace detail {
|
||||
|
||||
template<class, class, class, class>
|
||||
class basic_stream_connect_op;
|
||||
|
||||
struct any_endpoint
|
||||
{
|
||||
template<class Error, class Endpoint>
|
||||
|
@@ -179,151 +179,6 @@ struct basic_stream<Protocol, Executor, RatePolicy>::
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<
|
||||
class Protocol, class Executor, class RatePolicy,
|
||||
class Handler>
|
||||
class basic_stream_connect_op
|
||||
: public async_op_base<Handler, Executor>
|
||||
{
|
||||
using stream_type = beast::basic_stream<
|
||||
Protocol, Executor, RatePolicy>;
|
||||
|
||||
using timeout_handler =
|
||||
typename stream_type::timeout_handler;
|
||||
|
||||
boost::shared_ptr<typename
|
||||
stream_type::impl_type> impl_;
|
||||
typename stream_type::pending_guard pg0_;
|
||||
typename stream_type::pending_guard pg1_;
|
||||
|
||||
typename stream_type::op_state&
|
||||
state() noexcept
|
||||
{
|
||||
return impl_->write;
|
||||
}
|
||||
|
||||
public:
|
||||
template<class Handler_>
|
||||
basic_stream_connect_op(
|
||||
Handler_&& h,
|
||||
stream_type& s,
|
||||
typename stream_type::endpoint_type ep)
|
||||
: async_op_base<Handler, Executor>(
|
||||
std::forward<Handler_>(h), s.get_executor())
|
||||
, impl_(s.impl_)
|
||||
, pg0_(impl_->read.pending)
|
||||
, pg1_(impl_->write.pending)
|
||||
{
|
||||
if(state().timer.expiry() != stream_base::never())
|
||||
impl_->write.timer.async_wait(
|
||||
net::bind_executor(
|
||||
this->get_executor(),
|
||||
timeout_handler{
|
||||
state(),
|
||||
impl_,
|
||||
state().tick}));
|
||||
|
||||
impl_->socket.async_connect(
|
||||
ep, std::move(*this));
|
||||
// *this is now moved-from
|
||||
}
|
||||
|
||||
template<
|
||||
class Endpoints, class Condition,
|
||||
class Handler_>
|
||||
basic_stream_connect_op(
|
||||
Handler_&& h,
|
||||
stream_type& s,
|
||||
Endpoints const& eps,
|
||||
Condition const& cond)
|
||||
: async_op_base<Handler, Executor>(
|
||||
std::forward<Handler_>(h), s.get_executor())
|
||||
, impl_(s.impl_)
|
||||
, pg0_(impl_->read.pending)
|
||||
, pg1_(impl_->write.pending)
|
||||
{
|
||||
if(state().timer.expiry() != stream_base::never())
|
||||
impl_->write.timer.async_wait(
|
||||
net::bind_executor(
|
||||
this->get_executor(),
|
||||
timeout_handler{
|
||||
state(),
|
||||
impl_,
|
||||
state().tick}));
|
||||
|
||||
net::async_connect(impl_->socket,
|
||||
eps, cond, std::move(*this));
|
||||
// *this is now moved-from
|
||||
}
|
||||
|
||||
template<
|
||||
class Iterator, class Condition,
|
||||
class Handler_>
|
||||
basic_stream_connect_op(
|
||||
Handler_&& h,
|
||||
stream_type& s,
|
||||
Iterator begin, Iterator end,
|
||||
Condition const& cond)
|
||||
: async_op_base<Handler, Executor>(
|
||||
std::forward<Handler_>(h), s.get_executor())
|
||||
, impl_(s.impl_)
|
||||
, pg0_(impl_->read.pending)
|
||||
, pg1_(impl_->write.pending)
|
||||
{
|
||||
if(state().timer.expiry() != stream_base::never())
|
||||
impl_->write.timer.async_wait(
|
||||
net::bind_executor(
|
||||
this->get_executor(),
|
||||
timeout_handler{
|
||||
state(),
|
||||
impl_,
|
||||
state().tick}));
|
||||
|
||||
net::async_connect(impl_->socket,
|
||||
begin, end, cond, std::move(*this));
|
||||
// *this is now moved-from
|
||||
}
|
||||
|
||||
template<class... Args>
|
||||
void
|
||||
operator()(error_code ec, Args&&... args)
|
||||
{
|
||||
if(state().timer.expiry() != stream_base::never())
|
||||
{
|
||||
++state().tick;
|
||||
|
||||
// try cancelling timer
|
||||
auto const n =
|
||||
impl_->write.timer.cancel();
|
||||
if(n == 0)
|
||||
{
|
||||
// timeout handler invoked?
|
||||
if(state().timeout)
|
||||
{
|
||||
// yes, socket already closed
|
||||
ec = beast::error::timeout;
|
||||
state().timeout = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_ASSERT(n == 1);
|
||||
BOOST_ASSERT(! state().timeout);
|
||||
}
|
||||
}
|
||||
|
||||
pg0_.reset();
|
||||
pg1_.reset();
|
||||
this->invoke_now(ec, std::forward<Args>(args)...);
|
||||
}
|
||||
};
|
||||
|
||||
} // detail
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template<class Protocol, class Executor, class RatePolicy>
|
||||
struct basic_stream<Protocol, Executor, RatePolicy>::ops
|
||||
{
|
||||
@@ -530,6 +385,136 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
template<class Handler>
|
||||
class connect_op
|
||||
: public async_op_base<Handler, Executor>
|
||||
{
|
||||
boost::shared_ptr<impl_type> impl_;
|
||||
pending_guard pg0_;
|
||||
pending_guard pg1_;
|
||||
|
||||
op_state&
|
||||
state() noexcept
|
||||
{
|
||||
return impl_->write;
|
||||
}
|
||||
|
||||
public:
|
||||
template<class Handler_>
|
||||
connect_op(
|
||||
Handler_&& h,
|
||||
basic_stream& s,
|
||||
endpoint_type ep)
|
||||
: async_op_base<Handler, Executor>(
|
||||
std::forward<Handler_>(h), s.get_executor())
|
||||
, impl_(s.impl_)
|
||||
, pg0_(impl_->read.pending)
|
||||
, pg1_(impl_->write.pending)
|
||||
{
|
||||
if(state().timer.expiry() != stream_base::never())
|
||||
impl_->write.timer.async_wait(
|
||||
net::bind_executor(
|
||||
this->get_executor(),
|
||||
timeout_handler{
|
||||
state(),
|
||||
impl_,
|
||||
state().tick}));
|
||||
|
||||
impl_->socket.async_connect(
|
||||
ep, std::move(*this));
|
||||
// *this is now moved-from
|
||||
}
|
||||
|
||||
template<
|
||||
class Endpoints, class Condition,
|
||||
class Handler_>
|
||||
connect_op(
|
||||
Handler_&& h,
|
||||
basic_stream& s,
|
||||
Endpoints const& eps,
|
||||
Condition const& cond)
|
||||
: async_op_base<Handler, Executor>(
|
||||
std::forward<Handler_>(h), s.get_executor())
|
||||
, impl_(s.impl_)
|
||||
, pg0_(impl_->read.pending)
|
||||
, pg1_(impl_->write.pending)
|
||||
{
|
||||
if(state().timer.expiry() != stream_base::never())
|
||||
impl_->write.timer.async_wait(
|
||||
net::bind_executor(
|
||||
this->get_executor(),
|
||||
timeout_handler{
|
||||
state(),
|
||||
impl_,
|
||||
state().tick}));
|
||||
|
||||
net::async_connect(impl_->socket,
|
||||
eps, cond, std::move(*this));
|
||||
// *this is now moved-from
|
||||
}
|
||||
|
||||
template<
|
||||
class Iterator, class Condition,
|
||||
class Handler_>
|
||||
connect_op(
|
||||
Handler_&& h,
|
||||
basic_stream& s,
|
||||
Iterator begin, Iterator end,
|
||||
Condition const& cond)
|
||||
: async_op_base<Handler, Executor>(
|
||||
std::forward<Handler_>(h), s.get_executor())
|
||||
, impl_(s.impl_)
|
||||
, pg0_(impl_->read.pending)
|
||||
, pg1_(impl_->write.pending)
|
||||
{
|
||||
if(state().timer.expiry() != stream_base::never())
|
||||
impl_->write.timer.async_wait(
|
||||
net::bind_executor(
|
||||
this->get_executor(),
|
||||
timeout_handler{
|
||||
state(),
|
||||
impl_,
|
||||
state().tick}));
|
||||
|
||||
net::async_connect(impl_->socket,
|
||||
begin, end, cond, std::move(*this));
|
||||
// *this is now moved-from
|
||||
}
|
||||
|
||||
template<class... Args>
|
||||
void
|
||||
operator()(error_code ec, Args&&... args)
|
||||
{
|
||||
if(state().timer.expiry() != stream_base::never())
|
||||
{
|
||||
++state().tick;
|
||||
|
||||
// try cancelling timer
|
||||
auto const n =
|
||||
impl_->write.timer.cancel();
|
||||
if(n == 0)
|
||||
{
|
||||
// timeout handler invoked?
|
||||
if(state().timeout)
|
||||
{
|
||||
// yes, socket already closed
|
||||
ec = beast::error::timeout;
|
||||
state().timeout = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_ASSERT(n == 1);
|
||||
BOOST_ASSERT(! state().timeout);
|
||||
}
|
||||
}
|
||||
|
||||
pg0_.reset();
|
||||
pg1_.reset();
|
||||
this->invoke_now(ec, std::forward<Args>(args)...);
|
||||
}
|
||||
};
|
||||
|
||||
struct run_read_op
|
||||
{
|
||||
template<class ReadHandler, class Buffers>
|
||||
@@ -700,6 +685,8 @@ close()
|
||||
impl_->close();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template<class Protocol, class Executor, class RatePolicy>
|
||||
template<class ConnectHandler>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(ConnectHandler,
|
||||
@@ -711,8 +698,7 @@ async_connect(
|
||||
{
|
||||
BOOST_BEAST_HANDLER_INIT(
|
||||
ConnectHandler, void(error_code));
|
||||
detail::basic_stream_connect_op<
|
||||
Protocol, Executor, RatePolicy,
|
||||
ops::template connect_op<
|
||||
BOOST_ASIO_HANDLER_TYPE(
|
||||
ConnectHandler, void(error_code))>(
|
||||
std::forward<ConnectHandler>(handler),
|
||||
@@ -720,6 +706,98 @@ async_connect(
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
template<class Protocol, class Executor, class RatePolicy>
|
||||
template<
|
||||
class EndpointSequence,
|
||||
class RangeConnectHandler,
|
||||
class>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(RangeConnectHandler,
|
||||
void(error_code, typename Protocol::endpoint))
|
||||
basic_stream<Protocol, Executor, RatePolicy>::
|
||||
async_connect(
|
||||
EndpointSequence const& endpoints,
|
||||
RangeConnectHandler&& handler)
|
||||
{
|
||||
BOOST_BEAST_HANDLER_INIT(RangeConnectHandler,
|
||||
void(error_code, typename Protocol::endpoint));
|
||||
ops::template connect_op<
|
||||
BOOST_ASIO_HANDLER_TYPE(RangeConnectHandler,
|
||||
void(error_code, typename Protocol::endpoint))>(
|
||||
std::move(init.completion_handler), *this,
|
||||
endpoints, detail::any_endpoint{});
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
template<class Protocol, class Executor, class RatePolicy>
|
||||
template<
|
||||
class EndpointSequence,
|
||||
class ConnectCondition,
|
||||
class RangeConnectHandler,
|
||||
class>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(RangeConnectHandler,
|
||||
void (error_code, typename Protocol::endpoint))
|
||||
basic_stream<Protocol, Executor, RatePolicy>::
|
||||
async_connect(
|
||||
EndpointSequence const& endpoints,
|
||||
ConnectCondition connect_condition,
|
||||
RangeConnectHandler&& handler)
|
||||
{
|
||||
BOOST_BEAST_HANDLER_INIT(RangeConnectHandler,
|
||||
void(error_code, typename Protocol::endpoint));
|
||||
ops::template connect_op<
|
||||
BOOST_ASIO_HANDLER_TYPE(RangeConnectHandler,
|
||||
void(error_code, typename Protocol::endpoint))>(
|
||||
std::move(init.completion_handler), *this,
|
||||
endpoints, connect_condition);
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
template<class Protocol, class Executor, class RatePolicy>
|
||||
template<
|
||||
class Iterator,
|
||||
class IteratorConnectHandler>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(IteratorConnectHandler,
|
||||
void (error_code, Iterator))
|
||||
basic_stream<Protocol, Executor, RatePolicy>::
|
||||
async_connect(
|
||||
Iterator begin, Iterator end,
|
||||
IteratorConnectHandler&& handler)
|
||||
{
|
||||
BOOST_BEAST_HANDLER_INIT(IteratorConnectHandler,
|
||||
void(error_code, Iterator));
|
||||
ops::template connect_op<
|
||||
BOOST_ASIO_HANDLER_TYPE(IteratorConnectHandler,
|
||||
void(error_code, Iterator))>(
|
||||
std::move(init.completion_handler), *this,
|
||||
begin, end, detail::any_endpoint{});
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
template<class Protocol, class Executor, class RatePolicy>
|
||||
template<
|
||||
class Iterator,
|
||||
class ConnectCondition,
|
||||
class IteratorConnectHandler>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(IteratorConnectHandler,
|
||||
void (error_code, Iterator))
|
||||
basic_stream<Protocol, Executor, RatePolicy>::
|
||||
async_connect(
|
||||
Iterator begin, Iterator end,
|
||||
ConnectCondition connect_condition,
|
||||
IteratorConnectHandler&& handler)
|
||||
{
|
||||
BOOST_BEAST_HANDLER_INIT(IteratorConnectHandler,
|
||||
void(error_code, Iterator));
|
||||
ops::template connect_op<
|
||||
BOOST_ASIO_HANDLER_TYPE(IteratorConnectHandler,
|
||||
void(error_code, Iterator))>(
|
||||
std::move(init.completion_handler), *this,
|
||||
begin, end, connect_condition);
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template<class Protocol, class Executor, class RatePolicy>
|
||||
template<class MutableBufferSequence, class ReadHandler>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
|
||||
@@ -764,100 +842,6 @@ async_write_some(
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template<
|
||||
class Protocol, class Executor, class RatePolicy,
|
||||
class EndpointSequence,
|
||||
class RangeConnectHandler,
|
||||
class>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(RangeConnectHandler,
|
||||
void(error_code, typename Protocol::endpoint))
|
||||
async_connect(
|
||||
basic_stream<Protocol, Executor, RatePolicy>& stream,
|
||||
EndpointSequence const& endpoints,
|
||||
RangeConnectHandler&& handler)
|
||||
{
|
||||
BOOST_BEAST_HANDLER_INIT(RangeConnectHandler,
|
||||
void(error_code, typename Protocol::endpoint));
|
||||
detail::basic_stream_connect_op<
|
||||
Protocol, Executor, RatePolicy,
|
||||
BOOST_ASIO_HANDLER_TYPE(RangeConnectHandler,
|
||||
void(error_code, typename Protocol::endpoint))>(
|
||||
std::move(init.completion_handler), stream,
|
||||
endpoints, detail::any_endpoint{});
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
template<
|
||||
class Protocol, class Executor, class RatePolicy,
|
||||
class EndpointSequence,
|
||||
class ConnectCondition,
|
||||
class RangeConnectHandler,
|
||||
class>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(RangeConnectHandler,
|
||||
void (error_code, typename Protocol::endpoint))
|
||||
async_connect(
|
||||
basic_stream<Protocol, Executor, RatePolicy>& stream,
|
||||
EndpointSequence const& endpoints,
|
||||
ConnectCondition connect_condition,
|
||||
RangeConnectHandler&& handler)
|
||||
{
|
||||
BOOST_BEAST_HANDLER_INIT(RangeConnectHandler,
|
||||
void(error_code, typename Protocol::endpoint));
|
||||
detail::basic_stream_connect_op<
|
||||
Protocol, Executor, RatePolicy,
|
||||
BOOST_ASIO_HANDLER_TYPE(RangeConnectHandler,
|
||||
void(error_code, typename Protocol::endpoint))>(
|
||||
std::move(init.completion_handler), stream,
|
||||
endpoints, connect_condition);
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
template<
|
||||
class Protocol, class Executor, class RatePolicy,
|
||||
class Iterator,
|
||||
class IteratorConnectHandler>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(IteratorConnectHandler,
|
||||
void (error_code, Iterator))
|
||||
async_connect(
|
||||
basic_stream<Protocol, Executor, RatePolicy>& stream,
|
||||
Iterator begin, Iterator end,
|
||||
IteratorConnectHandler&& handler)
|
||||
{
|
||||
BOOST_BEAST_HANDLER_INIT(IteratorConnectHandler,
|
||||
void(error_code, Iterator));
|
||||
detail::basic_stream_connect_op<
|
||||
Protocol, Executor, RatePolicy,
|
||||
BOOST_ASIO_HANDLER_TYPE(IteratorConnectHandler,
|
||||
void(error_code, Iterator))>(
|
||||
std::move(init.completion_handler), stream,
|
||||
begin, end, detail::any_endpoint{});
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
template<
|
||||
class Protocol, class Executor, class RatePolicy,
|
||||
class Iterator,
|
||||
class ConnectCondition,
|
||||
class IteratorConnectHandler>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(IteratorConnectHandler,
|
||||
void (error_code, Iterator))
|
||||
async_connect(
|
||||
basic_stream<Protocol, Executor, RatePolicy>& stream,
|
||||
Iterator begin, Iterator end,
|
||||
ConnectCondition connect_condition,
|
||||
IteratorConnectHandler&& handler)
|
||||
{
|
||||
BOOST_BEAST_HANDLER_INIT(IteratorConnectHandler,
|
||||
void(error_code, Iterator));
|
||||
detail::basic_stream_connect_op<
|
||||
Protocol, Executor, RatePolicy,
|
||||
BOOST_ASIO_HANDLER_TYPE(IteratorConnectHandler,
|
||||
void(error_code, Iterator))>(
|
||||
std::move(init.completion_handler), stream,
|
||||
begin, end, connect_condition);
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// Customization points
|
||||
|
@@ -819,9 +819,9 @@ public:
|
||||
stream_type s(ioc);
|
||||
error_code ec;
|
||||
r.ep = a.ep;
|
||||
connect(s, r);
|
||||
s.connect(r);
|
||||
s.socket().close();
|
||||
connect(s, r, ec);
|
||||
s.connect(r, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
}
|
||||
|
||||
@@ -830,9 +830,9 @@ public:
|
||||
stream_type s(ioc);
|
||||
error_code ec;
|
||||
r.ep = a.ep;
|
||||
connect(s, r, cond);
|
||||
s.connect(r, cond);
|
||||
s.socket().close();
|
||||
connect(s, r, cond, ec);
|
||||
s.connect(r, cond, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
}
|
||||
|
||||
@@ -841,9 +841,9 @@ public:
|
||||
stream_type s(ioc);
|
||||
error_code ec;
|
||||
r.ep = a.ep;
|
||||
connect(s, r.begin(), r.end());
|
||||
s.connect(r.begin(), r.end());
|
||||
s.socket().close();
|
||||
connect(s, r.begin(), r.end(), ec);
|
||||
s.connect(r.begin(), r.end(), ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
}
|
||||
|
||||
@@ -852,9 +852,9 @@ public:
|
||||
stream_type s(ioc);
|
||||
error_code ec;
|
||||
r.ep = a.ep;
|
||||
connect(s, r.begin(), r.end(), cond);
|
||||
s.connect(r.begin(), r.end(), cond);
|
||||
s.socket().close();
|
||||
connect(s, r.begin(), r.end(), cond, ec);
|
||||
s.connect(r.begin(), r.end(), cond, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
}
|
||||
|
||||
@@ -881,12 +881,12 @@ public:
|
||||
stream_type s(ioc);
|
||||
r.ep = a.ep;
|
||||
s.expires_never();
|
||||
async_connect(s, r, range_handler{});
|
||||
s.async_connect(r, range_handler{});
|
||||
ioc.run();
|
||||
ioc.restart();
|
||||
s.socket().close();
|
||||
s.expires_after(std::chrono::seconds(30));
|
||||
async_connect(s, r, range_handler{});
|
||||
s.async_connect(r, range_handler{});
|
||||
ioc.run();
|
||||
ioc.restart();
|
||||
}
|
||||
@@ -896,12 +896,12 @@ public:
|
||||
stream_type s(ioc);
|
||||
r.ep = a.ep;
|
||||
s.expires_never();
|
||||
async_connect(s, r, cond, range_handler{});
|
||||
s.async_connect(r, cond, range_handler{});
|
||||
ioc.run();
|
||||
ioc.restart();
|
||||
s.socket().close();
|
||||
s.expires_after(std::chrono::seconds(30));
|
||||
async_connect(s, r, cond, range_handler{});
|
||||
s.async_connect(r, cond, range_handler{});
|
||||
ioc.run();
|
||||
ioc.restart();
|
||||
}
|
||||
@@ -911,13 +911,13 @@ public:
|
||||
stream_type s(ioc);
|
||||
r.ep = a.ep;
|
||||
s.expires_never();
|
||||
async_connect(s, r.begin(), r.end(),
|
||||
s.async_connect(r.begin(), r.end(),
|
||||
iterator_handler{});
|
||||
ioc.run();
|
||||
ioc.restart();
|
||||
s.socket().close();
|
||||
s.expires_after(std::chrono::seconds(30));
|
||||
async_connect(s, r.begin(), r.end(),
|
||||
s.async_connect(r.begin(), r.end(),
|
||||
iterator_handler{});
|
||||
ioc.run();
|
||||
ioc.restart();
|
||||
@@ -928,18 +928,18 @@ public:
|
||||
stream_type s(ioc);
|
||||
r.ep = a.ep;
|
||||
s.expires_never();
|
||||
async_connect(s, r.begin(), r.end(), cond,
|
||||
s.async_connect(r.begin(), r.end(), cond,
|
||||
iterator_handler{});
|
||||
ioc.run();
|
||||
ioc.restart();
|
||||
s.socket().close();
|
||||
s.expires_after(std::chrono::seconds(30));
|
||||
async_connect(s, r.begin(), r.end(), cond,
|
||||
s.async_connect(r.begin(), r.end(), cond,
|
||||
iterator_handler{});
|
||||
ioc.run();
|
||||
ioc.restart();
|
||||
}
|
||||
|
||||
#if 0
|
||||
// use_future
|
||||
|
||||
BEAST_EXPECT(static_cast<std::future<
|
||||
@@ -999,6 +999,7 @@ public:
|
||||
connect_condition const&,
|
||||
net::yield_context&&)>(
|
||||
&beast::async_connect));
|
||||
#endif
|
||||
|
||||
//
|
||||
// async_connect timeout
|
||||
|
@@ -62,7 +62,7 @@ boost::ignore_unused(ec);
|
||||
net::ip::tcp::resolver r(ioc);
|
||||
stream<tcp_stream> ws(ioc);
|
||||
auto const results = r.resolve(host, "ws");
|
||||
connect(get_lowest_layer(ws), results.begin(), results.end());
|
||||
get_lowest_layer(ws).connect(results.begin(), results.end());
|
||||
//]
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user