#include <stdio.h>
#include <time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>

main(int argc, char *argv[])
{
	struct addrinfo	hints, *res;
	int		rc;
	char		sbuf[NI_MAXSERV];
	int		port = 80;
	time_t		now, then;
	int		i;

	--argc;
	++argv;
	for (i = 0; i < argc; ++i)
	{
		time(&then);

		memset(&hints, 0, sizeof(hints));
		hints.ai_family = PF_UNSPEC;
		hints.ai_socktype = SOCK_STREAM;
		hints.ai_flags = AI_CANONNAME;
		snprintf(sbuf, sizeof(sbuf), "%d", port);

		rc = getaddrinfo(argv[i], sbuf, &hints, &res);

		time(&now);

		printf("%s: rc = %d, time = %d secs\n",
				argv[i], rc, now - then);
	}

	exit(0);
}


