1 /* this program is used to test that getaddrinfo() works correctly
2 * without a 'hints' argument
6 #include <sys/socket.h>
9 #include <stdio.h> /* for printf */
10 #include <string.h> /* for memset */
11 #include <netinet/in.h> /* for IPPROTO_TCP */
13 #define SERVER_NAME "www.android.com"
14 #define PORT_NUMBER "9999"
18 struct addrinfo hints;
22 /* first, try without any hints */
23 ret = getaddrinfo( SERVER_NAME, PORT_NUMBER, NULL, &res);
25 printf("first getaddrinfo returned error: %s\n", gai_strerror(ret));
31 /* now try with the hints */
32 memset(&hints, 0, sizeof(hints));
33 hints.ai_family = AF_UNSPEC;
34 hints.ai_socktype = SOCK_STREAM;
35 hints.ai_protocol = IPPROTO_TCP;
37 ret = getaddrinfo( SERVER_NAME, PORT_NUMBER, &hints, &res );
39 printf("second getaddrinfo returned error: %s\n", gai_strerror(ret));