programatically retrieving my IP address

Hi All,

I am running an application program that would like to determine its current IP address. In the LITE5200B boards, that information is saved as an “environmental variable”, but I don’t believe the environmental variable is available when I boot from FLASH. My build file has already executed an “ifconfig en0 inet 192.168.1.11” when my application starts running, but I have not been able to find a way to get my IP address. Probably something simple…

Any suggestions or references to a particular document would be appreciated. Thanks!

StevenK.

try to google it up. in fact it’s been answer a couple of time on openqnx.com. This is not related to QNX so answer is easier to find ;-0

Hi Mario,

The solutions I’ve seen on the Internet over the last couple of days use gethostname and gethostbyname, which ultimately try to read the /etc/hosts file - which I do not have on my embedded controller. My hope was that QNX would have some other way of doing it internally. A coworker suggested spawning an “ifconfig” and parsing the IP address out of that! :smiley:

I have the workaround of creating a variable in my build script that my application can access, so I may just stick with that.

Thanks anyhow!

StevenK.

as Mario said, it is not related to QNX, you probably could have found the answer by yourself,
anyway, here it is: openqnx.com/index.php?name=P … highlight=

Thank you, mezek. Very much appreciated!

StevenK.