boost::corosio::connect
connect overloads
Synopses
Declared in <boost/corosio/connect.hpp>
Asynchronously connect a socket by trying each endpoint in a range.
template<
class Socket,
std::ranges::input_range Range>
requires std::convertible_to<
std::ranges::range_reference_t<Range>,
typename Socket::endpoint_type>
capy::task<capy::io_result<Socket::endpoint_type>>
connect(
Socket& s,
Range endpoints);
Asynchronously connect a socket by trying each endpoint in an iterator range.
template<
class Socket,
std::input_iterator Iter>
requires std::convertible_to<
std::iter_reference_t<Iter>,
typename Socket::endpoint_type>
capy::task<capy::io_result<Iter>>
connect(
Socket& s,
Iter begin,
Iter end);
Asynchronously connect a socket by trying each endpoint in a range, filtered by a user‐supplied condition.
template<
class Socket,
std::ranges::input_range Range,
class ConnectCondition>
requires std::convertible_to<
std::ranges::range_reference_t<Range>,
typename Socket::endpoint_type> &&
std::predicate<
ConnectCondition&,
std::error_code const&,
typename Socket::endpoint_type const&>
capy::task<capy::io_result<Socket::endpoint_type>>
connect(
Socket& s,
Range endpoints,
ConnectCondition cond);
Asynchronously connect a socket by trying each endpoint in an iterator range, filtered by a user‐supplied condition.
template<
class Socket,
std::input_iterator Iter,
class ConnectCondition>
requires std::convertible_to<
std::iter_reference_t<Iter>,
typename Socket::endpoint_type> &&
std::predicate<
ConnectCondition&,
std::error_code const&,
typename Socket::endpoint_type const&>
capy::task<capy::io_result<Iter>>
connect(
Socket& s,
Iter begin,
Iter end,
ConnectCondition cond);
Exceptions
Name |
Thrown on |
|
if auto‐opening the socket fails during an attempt (inherits the contract of |
Return Value
-
An awaitable completing with
capy::io_result<typename Socket::endpoint_type>: ‐ on success: default error_code and the connected endpoint; ‐ on failure of all attempts: the error from the last attempt and a default‐constructed endpoint; ‐ on empty range:std::errc::no_such_device_or_addressand a default‐constructed endpoint. -
An awaitable completing with
capy::io_result<Iter>: ‐ on success: default error_code and the iterator of the successful endpoint; ‐ on failure of all attempts: the error from the last attempt andend; ‐ on empty range:std::errc::no_such_device_or_addressandend. -
Same as the non‐condition overload. If every candidate is rejected, completes with
std::errc::no_such_device_or_address. -
Same as the plain iterator overload. If every candidate is rejected, completes with
std::errc::no_such_device_or_address.
Parameters
Name |
Description |
s |
The socket to connect. Must have a |
endpoints |
A range of candidate endpoints. Taken by value so temporaries (e.g. |
begin |
The first candidate. |
end |
One past the last candidate. |
cond |
A predicate invocable with |
Created with MrDocs