This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Question about getaddrinfo taking 20 seconds


Hi,

I have a dns-related question. The following program shows here 20 seconds, which means that getaddrinfo with AI_CANONNAME takes 20 seconds. Is it normal?

#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <iostream>
using namespace std;

int main ()
{
  struct timeval tv1, tv2;
  gettimeofday (&tv1, NULL);
  const char *name = "stun.ekiga.net";
  cout << "start " << name << "\n";
    struct addrinfo *res = NULL;
    static struct addrinfo hints = { AI_CANONNAME, PF_INET };
    getaddrinfo((const char *)name, NULL , &hints, &res);
  gettimeofday (&tv2, NULL);
  cout << "end, time elapsed: " << tv2.tv_sec - tv1.tv_sec << "secs\n";
  return 0;
}

Thank you for your help,
--
Eugen Dedu
http://eugen.dedu.free.fr


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]