#include #include #include #include #include #include const NTHREADS = 300; char *name = "www.google.com"; void lookup(void *arg) { struct addrinfo *res; struct addrinfo hints; memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_flags = AI_ALL | AI_V4MAPPED | AI_CANONNAME; int e = getaddrinfo(name, NULL, &hints, &res); if (e != 0) { if (e == EAI_NONAME) { printf("no such host\n", e); } else { printf("error %d\n", e); } return; } freeaddrinfo(res); } int main() { pthread_t threads[NTHREADS]; int i; for (i = 0; i < NTHREADS; ++i) { pthread_create(&threads[i], NULL, lookup, NULL); } for (i = 0; i < NTHREADS; ++i) { pthread_join(threads[i], NULL); } return 0; }