01-27-05 10:52 PM
"BM" <b.marsh@gmx.net> wrote in message
news:1106858791.993371.9910@z14g2000cwz.googlegroups.com...
> Hi all,
>
> i'm having problems grabbing the IP out of the h_addr_list (or h_addr)
> sturct on a
> freshly gethostbyname'd hostent structure.
>
> observe:
>
> struct in_addr **address;
>
> ......
>
> if((h=gethostbyname(node)) == NULL) {
> herror("gethostbyname");
> exit(1);
> }
>
> address=(struct in_addr **)h->h_addr;
>
> for(; *address != NULL; address++);
> printf("addr: %s\n",*address);
> exit(1);
>
>
> just to purely see if I can get the address..
> I am unable to get the IP...
>
> can anyone help pls?
>
> thanks
>
> bm
>
Your printf is incorrect. If you want to print it, you need to do a
inet_ntoa(*address).
As in printf("addr: %s\n", inet_ntoa(*address));
--
Fletcher Glenn
[ Post a follow-up to this message ]
|