JvmDnsResolver
fun JvmDnsResolver(dispatcher: CoroutineDispatcher = Dispatchers.IO): suspend (hostname: String) -> List<String>(source)
Returns a CIOEngineConfig.dnsResolver backed by java.net.InetAddress.getAllByName, dispatched on dispatcher and wrapped in runInterruptible so cancellation/withTimeout actually unblocks the resolver thread.
The underlying JVM call is still a blocking system call, but it is moved off the calling coroutine and is interruptible — addressing the timeout-control complaint of KTOR-462 / #1678 while preserving native OS resolver behavior (/etc/hosts, mDNS, search domains, custom NSS).
HttpClient(CIO) {
engine { dnsResolver = JvmDnsResolver() }
install(HttpTimeout) { connectTimeoutMillis = 3000 }
}Content copied to clipboard
For a fully non-blocking resolver that bypasses the OS name service, see CioDnsResolver.