On Tue, Sep 18, 2007 at 08:41:45PM +0200, Kurt Roeckx wrote:
> I've attached a small test program.  The results are:
> sarge: libc6 2.3.2.ds1-22sarge5: random order
> etch: libc6 2.3.6.ds1-13etch2: ordered results

Maybe I should attach it.


Kurt

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

int main()
{
	struct addrinfo *res, *p, hints;

	hints.ai_flags = 0;
	hints.ai_family = PF_UNSPEC;
	hints.ai_socktype = SOCK_DGRAM;
	hints.ai_protocol = 0;
	hints.ai_addrlen = 0;
	hints.ai_addr = NULL;
	hints.ai_canonname = NULL;
	hints.ai_next = NULL;

	getaddrinfo("0.pool.ntp.org", "ntp", &hints, &res);

	for (p = res; p; p = p->ai_next)
	{
		if (p->ai_family == AF_INET)
		{
			char ip[INET_ADDRSTRLEN];
			if (inet_ntop(p->ai_family,
				&(*(struct sockaddr_in *)p->ai_addr).sin_addr,
				ip, sizeof(ip)) != NULL)
			{
				printf("%s\n", ip);
			}
		}
	}
	freeaddrinfo(res);
	return 0;
}

Reply via email to