java - 主机查找的默认超时是多少?

标签 java sockets dns timeout

与此问题相关:How to set the timeout for socket when looking for host? ,我发现了解主机查找的默认超时很重要

如果超时很短,例如几分钟后,我认为什么也不做是安全的。如果它很长,例如几个小时,我必须为其设置超时。

查找主机时套接字的默认超时时间是多少?

最佳答案

JNDI Docs提供此信息:

The DNS provider submits UDP queries using the following exponential backoff algorithm. The provider submits a query to a DNS server and waits for a response to arrive within a timeout period (1 second by default). If it receives no response within the timeout period, it queries the next server, and so on. If the provider receives no response from any server, it doubles the timeout period and repeats the process of submitting the query to each server, up to a maximum number of retries (4 by default).

因此,这取决于您的配置中包含的 DNS 服务器数量,但默认初始值为 1 秒,如果所有服务器都失败,则每台服务器需要 31 秒; 1 + 2 + 4 + 8 + 16 = 31。(初始尝试 + 4 次重试)

关于java - 主机查找的默认超时是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21088089/

相关文章:

c - 获取地址信息(): how to distinguish between resolution failure and non-resolvable hostname?

java - Android 蓝牙套接字连接使用 AsyncTask 在后台接收数据

dns - 什么是 XMPP 域名?

java - 构建休息服务器

java - SQL 表没有行

C 服务器套接字 - bind() 错误

java - IP 数据报中有效负载/数据的大小是如何决定的

c++ - 我拥有此 AD 域的管理员帐户,如何模拟另一个域用户?

java - 当表有八列时,在数据库条目中搜索匹配项

java - 使用 keyreleased 事件根据另一个单元格中的条目设置 jtable 中的单元格值