Hi,
i have seen this thread:
getnameinfo()
and i have also tried it
so, my code is the following:
Code:
int main(int argc, char * argv[])
{
struct sockaddr_in sa;
char node[NI_MAXHOST];
sa.sin_family = AF_INET;
inet_pton(AF_INET, "8.8.178.110", &sa.sin_addr); /* Host: www.freebsd.org ; official host name: wfe0.ysv.freebsd.org*/
int res = getnameinfo((struct sockaddr*)&sa, sizeof(sa), node, sizeof(node), NULL, 0, NI_NUMERICSERV | NI_NUMERICHOST );
if (res)
{
printf("error: %d\n", res);
printf("%s\n", gai_strerror(res));
}
printf("node=%s\n", node);
printf("error: %d\n", res);
printf("%s\n", gai_strerror(res));
return 0;
}
my compile options are the follwing:
Code:
tt: tt.c
reset
#gcc -Wall -ansi -pedantic tt.c -o tt
gcc tt.c -o tt
everything works and compiles great, but instead of the hostname i get again the IP address and i dont know why
smb is able to help me?
i thank u in advance for the help