48 {
49 Resolver resolver{*
loop_};
50
51 AddressHandle address =
53
54 uv_connect_t req;
57
58 auto tcp = std::make_unique<uv_tcp_t>();
59
62 uv_tcp_connect(&req, tcp.get(), address.sockaddr(),
onConnect);
63 if (connectStatus < 0) {
64
66 throw UvcoException(connectStatus,
67 "TcpClient::connect() failed immediately");
68 }
69
71 if (awaitStatus < 0) {
73 throw UvcoException(awaitStatus, "TcpClient::connect() failed");
74 }
75
76 co_return TcpStream{std::move(tcp)};
77}
uv_loop_t * uvloop() const
Get a non-owned pointer to the loop.
Definition loop.cc:62
Promise< TcpStream > connect()
Definition tcp.cc:48
static void onConnect(uv_connect_t *req, uv_status status)
Definition tcp.cc:79
int uv_status
Result of a libuv operation, an errno error code.
Definition internal_utils.h:22
Promise< void > closeHandle(T *handle, C closer)
Definition close.h:28