Reputation: 1
I use function getaddrinfo to get the ip address of domain name, OS = linux, language = c++. I noticed that when the ethernet cable is unplugged that function can block thread for 30 seconds (function doesn't return within 30 seconds). It's too long time for me. Is it possible to set timeout for that function or break the execution of function or any other idea ?
Thanks EB
Upvotes: 0
Views: 3055
Reputation: 204768
glibc provies getaddrinfo_a
, which allows for asynchronous name lookup (e.g. not blocking).
More portably, there are other asynchronous resolvers like adns and c-ares. Or you could just run the resolver in another thread.
Upvotes: 2