boost::corosio::tcp_socket::connect
Initiate an asynchronous connect operation.
Synopsis
Declared in <boost/corosio/tcp_socket.hpp>
auto
connect(endpoint ep);
Description
Connects the socket to the specified remote endpoint. The socket must be open before calling this function.
The operation supports cancellation via std::stop_token through the affine awaitable protocol. If the associated stop token is triggered, the operation completes immediately with errc::operation_canceled.
Return Value
An awaitable that completes with io_result<>. Returns success (default error_code) on successful connection, or an error code on failure including: ‐ connection_refused: No server listening at endpoint ‐ timed_out: Connection attempt timed out ‐ network_unreachable: No route to host ‐ operation_canceled: Cancelled via stop_token or cancel(). Check ec == cond::canceled for portable comparison.
Parameters
| Name | Description |
|---|---|
ep |
The remote endpoint to connect to. |
Created with MrDocs