connectTcp

suspend fun NetworkRuntime.connectTcp(host: String, port: Int, connectTimeoutMs: Long = 0, bypassProxy: Boolean = false): TcpConnection

Open a TCP connection to host:port, tunnelling through NetworkRuntime.proxy if set.

connectTimeoutMs, when positive, caps the time spent establishing the connection (and, for a proxied dial, the proxy negotiation too); a non-positive value (the default) waits indefinitely, preserving the previous behaviour. This mirrors libtorrent's socks5::on_connect_timeout 10-second guard on the control connection. On expiry the partially-opened socket is closed and a kotlinx.coroutines.TimeoutCancellationException propagates.