Initiate async_connect for an outbound endpoint.
On success: transitions to OPEN, starts receive chain. On failure: transitions to ERROR or RECONNECTING.
344{
345 asio::error_code ec;
346 auto addr = asio::ip::make_address(conn.info.remote_address, ec);
347 if (ec) {
349 "Invalid remote address '{}': {}", conn.info.remote_address, ec.message());
351 return;
352 }
353
354 asio::ip::tcp::endpoint target(addr, conn.info.remote_port);
355
356 conn.socket.async_connect(
357 target,
358 [this, ep_id = conn.info.id](const asio::error_code& connect_ec) {
359 std::shared_lock lock(m_connections_mutex);
360 auto it = m_connections.find(ep_id);
361 if (it == m_connections.end()) {
362 return;
363 }
364
365 auto& c = *it->second;
366
367 if (connect_ec) {
369 "TCP connect failed for endpoint {}: {}",
370 ep_id, connect_ec.message());
371
375 } else {
377 }
378 return;
379 }
380
383
385 "TCP endpoint {} connected to {}:{}",
386 ep_id, c.info.remote_address, c.info.remote_port);
387 });
388}
#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.