.
[glibc/history.git] / inet / tst-getni1.c
blob0e8a792f495ef6028e83e44f4978cfa6527fc965
1 #include <netdb.h>
2 #include <stdio.h>
3 #include <sys/socket.h>
5 static int
6 do_test (void)
8 int retval = 0;
10 struct sockaddr_in s;
11 s.sin_family = AF_INET;
12 s.sin_port = 80;
13 s.sin_addr.s_addr = INADDR_LOOPBACK;
14 int r = getnameinfo((struct sockaddr *) &s, sizeof (s), NULL, 0, NULL, 0,
15 NI_NUMERICHOST | NI_NUMERICSERV);
16 printf("r = %d\n", r);
17 if (r != 0)
19 puts ("failed without NI_NAMEREQD");
20 retval = 1;
23 r = getnameinfo((struct sockaddr *) &s, sizeof (s), NULL, 0, NULL, 0,
24 NI_NUMERICHOST | NI_NUMERICSERV | NI_NAMEREQD);
25 printf("r = %d\n", r);
26 if (r != EAI_NONAME)
28 puts ("did not fail with EAI_NONAME with NI_NAMEREQD set");
29 retval = 1;
32 return retval;
35 #define TEST_FUNCTION do_test ()
36 #include "../test-skeleton.c"