method to determine ip address

Is there a call that returns the ip of a certain interface? I can parse the
hosts file but that’s crude, I could catch and parse the output from
popen(“ifconfig en1”) - again crude. Perhaps the low down and dirty that
ifconfig actually calls?

Thanks.

Doug Rixmann <rixmannd@rdsdata.com> wrote:

Is there a call that returns the ip of a certain interface? I can parse the
hosts file but that’s crude, I could catch and parse the output from
popen(“ifconfig en1”) - again crude. Perhaps the low down and dirty that
ifconfig actually calls?

ioclt SIOCGIFADDR on a opened socket.

-xtang

Is there a method without opening a socket? This is what ifconfig does?

“Xiaodan Tang” <xtang@qnx.com> wrote in message
news:a97vmm$ar0$1@nntp.qnx.com

Doug Rixmann <> rixmannd@rdsdata.com> > wrote:
Is there a call that returns the ip of a certain interface? I can parse
the
hosts file but that’s crude, I could catch and parse the output from
popen(“ifconfig en1”) - again crude. Perhaps the low down and dirty that
ifconfig actually calls?

ioclt SIOCGIFADDR on a opened socket.

-xtang

Doug Rixmann <rixmannd@rdsdata.com> wrote:

Is there a method without opening a socket? This is what ifconfig does?

ifconfig() opens a socket and does an ioctl.

I don’t think there is a way without opening a socket.

-David

“Xiaodan Tang” <> xtang@qnx.com> > wrote in message
news:a97vmm$ar0$> 1@nntp.qnx.com> …
Doug Rixmann <> rixmannd@rdsdata.com> > wrote:
Is there a call that returns the ip of a certain interface? I can parse
the
hosts file but that’s crude, I could catch and parse the output from
popen(“ifconfig en1”) - again crude. Perhaps the low down and dirty that
ifconfig actually calls?

ioclt SIOCGIFADDR on a opened socket.

-xtang


QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.