Re: Asynchronous DNS name resolution / DNS timeouts




root wrote:
Sometimes I find that when DNS name resolution is not immediately
successful, gethostbyname() may block for unacceptable time, causing my
client program to become unresponsive. My question is, how should I
implement either DNS timeouts, or totally asynchronous DNS name
resolution? Do I need to write a proper DNS client from scratch from the
RFC? This is worse on some platforms than others.
Also gethostbyname() is poor because it is returning a pointer to static
data structure, and I currently must use mutexes to protect this call in
the multithreaded code. My code must be portable across HP/UX, Irix,
AIX, Linux, Solaris, Tru64, and Windows, so I have minimal choice about
what functions to use (gethostbyname_r() not supported on everything)

Try calling alarm() before the call to gethostbyname(), so that it is
interrupted when the alarm timeout reaches and SIGALRM is sent to your
application.

.



Relevant Pages

  • Asynchronous DNS name resolution / DNS timeouts
    ... Sometimes I find that when DNS name resolution is not immediately successful, gethostbyname() may block for unacceptable time, causing my client program to become unresponsive. ...
    (comp.unix.programmer)
  • Re: resolv order /etc/hosts file
    ... It works on my home network, but there I'm using dnsmasq not bind. ... DNS was invented and the ability to have a distributed ... The implementation of gethostbyname() was ...
    (comp.unix.admin)
  • gethostbyname problem
    ... I am trying to resolve the DNS to get the IP using IP helper API ... WSADATA wsaData; ... In this case for the very first time DNS is resolved and IP is given. ... But when try to use the same thing for the second time gethostbyname ...
    (microsoft.public.windowsce.embedded.vc)
  • gethostbyname problem
    ... I am trying to resolve the DNS to get the IP using IP helper API ... WSADATA wsaData; ... In this case for the very first time DNS is resolved and IP is given. ... But when try to use the same thing for the second time gethostbyname ...
    (microsoft.public.pocketpc.developer)
  • gethostbyname problem
    ... I am trying to resolve the DNS to get the IP using IP helper API ... WSADATA wsaData; ... In this case for the very first time DNS is resolved and IP is given. ... But when try to use the same thing for the second time gethostbyname ...
    (microsoft.public.windowsce.embedded)