Hi all,
Im using gethostbyname() to resolve a domain name or IP but i am having trouble trying to return readable data from the member function h_addr_list[0]. Here is a code snippit of what im trying to do ..
struct hostent *he
.
if((he=gethostbyname(host))==NULL) {
exit(-1); /*exit on failue*/
}
my problem is in trying to print the data held in he->h_addr_list[0]. I think im wright in saying that _addr_list[0] is returned in network byte order so no coversion is needed using htonl, i have also tried using inet_ntoa(*((struct in_addr *)he->h_addr_list[0])) with no success.
Can someone please tel me where im going wrong here, and possably point me in the wright direction?
Thanks in advance,
J@yb0t
Always know what you say, but don't always say what you know!
Im using gethostbyname() to resolve a domain name or IP but i am having trouble trying to return readable data from the member function h_addr_list[0]. Here is a code snippit of what im trying to do ..
struct hostent *he
.
if((he=gethostbyname(host))==NULL) {
exit(-1); /*exit on failue*/
}
my problem is in trying to print the data held in he->h_addr_list[0]. I think im wright in saying that _addr_list[0] is returned in network byte order so no coversion is needed using htonl, i have also tried using inet_ntoa(*((struct in_addr *)he->h_addr_list[0])) with no success.
Can someone please tel me where im going wrong here, and possably point me in the wright direction?
Thanks in advance,
J@yb0t
Always know what you say, but don't always say what you know!