[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [tor-talk] glibc's DNS lookups fail



Arg, I am not even sure whether glibc is the problem.  A minimal sample
application that performs lookups performs just fine.

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

int main(int argc, char** argv)
{
	struct addrinfo hints;
	memset(&hints, 0, sizeof(struct addrinfo));
	hints.ai_family = AF_INET;
	hints.ai_socktype = SOCK_STREAM;
	hints.ai_protocol = IPPROTO_TCP;

	printf("%s\n", argv[1]);

	struct addrinfo* result;
	int r=getaddrinfo(argv[1], NULL, &hints, &result);
	if(!r)
	{
		struct addrinfo* rp;
		for (rp = result; rp != NULL; rp = rp->ai_next)
		{
			size_t c;
			for(c=0;c!=14;++c)
			{
				printf("%u ", *(unsigned char*)(&rp->ai_addr->sa_data[c]));
			}
			printf("\n");
		}

		freeaddrinfo(result);
	}
	else
	{
		printf("%s\n", gai_strerror(r));
	}
}
================================================================================


_______________________________________________
tor-talk mailing list
tor-talk@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-talk