MyAddrs - getting my IpAddress

bridged with qdn.public.ddk.network
Post Reply
Ian Macafee

MyAddrs - getting my IpAddress

Post by Ian Macafee » Wed Sep 10, 2003 1:04 pm

Does any one know why the following returns NULL after the call to
gethostbyname?

myname.node name contains the correct Host Name.

//## operation MyAddrs()
char ** MyAddrs() {
//#[ operation MyAddrs()
struct hostent *hptr;
struct utsname myname;

if (uname(&myname) < 0 )
{
return NULL;
}

if ((hptr = gethostbyname(myname.nodename)) == NULL)
{
return NULL;
}
return (hptr->h_addr_list);
//#]
}

Sean Boudreau

Re: MyAddrs - getting my IpAddress

Post by Sean Boudreau » Wed Sep 10, 2003 1:07 pm

Look at the docs for /etc/resolv.conf in the utilities reference
for info on specifying your name server(s) and / or setting up your
/etc/hosts file.


-seanb

Ian Macafee <imacafee@radamec.co.uk> wrote:
Does any one know why the following returns NULL after the call to
gethostbyname?

myname.node name contains the correct Host Name.

//## operation MyAddrs()
char ** MyAddrs() {
//#[ operation MyAddrs()
struct hostent *hptr;
struct utsname myname;

if (uname(&myname) < 0 )
{
return NULL;
}

if ((hptr = gethostbyname(myname.nodename)) == NULL)
{
return NULL;
}
return (hptr->h_addr_list);
//#]
}

Post Reply

Return to “qdn.public.ddk.network”