Reputation: 2403
The ctor for Socket has versions that take the server as either a string or InetAddress. Are the results of the DNS lookup cached, so that another constructed Socket will skip performing the lookup and use the cached value, if available? And if so, does this apply to both versions, or just the one taking an InetAddress?
Upvotes: 2
Views: 1036
Reputation: 311046
Does Java Socket cache DNS?
No, but InetAddress
does, or something under its hood, and Socket
uses InetAddress
to resolve names, so in effect yes.
See the Java Networking Properties, networkaddress.cache.ttl
and friends.
Upvotes: 3