Looking for a way how to resolve IPv4/IPv6 address for a given fully qualified domain name, however in a limited time.
I've tried several ways with a standard Ruby library, but all of them block other threads so timeout exception can't take effect:
Timeout.timeout(1) {addr = Socket.sockaddr_in 80,'google.com'}
Timeout.timeout(1) {addr = Socket.getaddrinfo 'google.com','http',nil,:STREAM}
Timeout.timeout(1) {addr = Socket.gethostbyname 'google.com'}
When DNS response is slow or momentarily inaccessible, all of above attempts won't stop sooner then in about 60 seconds instead of given 1 second.
I'm aware of adns but it is not usualy available and requires an extra package to be installed.
Is there some other solution ?