Initiate async_connect for an outbound endpoint.
On success: transitions to OPEN, starts receive chain. On failure: transitions to ERROR or RECONNECTING.
348{
349 asio::error_code ec;
350 auto addr = asio::ip::make_address(conn.info.remote_address, ec);
351 if (ec) {
353 "Invalid remote address '{}': {}", conn.info.remote_address, ec.message());
355 return;
356 }
357
358 asio::ip::tcp::endpoint target(addr, conn.info.remote_port);
359
360 conn.socket.async_connect(
361 target,
362 [this, ep_id = conn.info.id](const asio::error_code& connect_ec) {
363 std::shared_lock lock(m_connections_mutex);
364 auto it = m_connections.find(ep_id);
365 if (it == m_connections.end()) {
366 return;
367 }
368
369 auto& c = *it->second;
370
371 if (connect_ec) {
373 "TCP connect failed for endpoint {}: {}",
374 ep_id, connect_ec.message());
375
379 } else {
381 }
382 return;
383 }
384
387
389 "TCP endpoint {} connected to {}:{}",
390 ep_id, c.info.remote_address, c.info.remote_port);
391 });
392}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
void start_receive_chain(ConnectionState &conn)
Start the framed message receive chain on a connection.
void transition_state(EndpointInfo &info, EndpointState new_state)
void schedule_reconnect(ConnectionState &conn)
Schedule a reconnect attempt after the configured interval.
@ NetworkBackend
Network transport backend (UDP, TCP, SHM)
@ Core
Core engine, backend, subsystems.