Do you have a question? Post it now! No Registration Necessary
Subject
- Posted on
How to get ip address from C application
- 05-21-2010
- Miloserdin Oleg
May 21, 2010, 4:52 pm

I'm interesting how to get IP address from C application. I've used
gethostname() and gethostbyname() in my application. I've edited /etc/hosts
file to add board's hostname and IP address. My board is connected to server
which using DHCP. If I remove added lines from /etc/hosts gethostbyname()
function returns error.
How can I get IP address from my application without using /etc/hosts
editing?
gethostname() and gethostbyname() in my application. I've edited /etc/hosts
file to add board's hostname and IP address. My board is connected to server
which using DHCP. If I remove added lines from /etc/hosts gethostbyname()
function returns error.
How can I get IP address from my application without using /etc/hosts
editing?
--
Best regards,
Miloserdin Oleg
Best regards,
Miloserdin Oleg
We've slightly trimmed the long signature. Click to see the full one.

Re: How to get ip address from C application

You're going to have to explain what you mean by "get IP address".

Again, what do you mean by "get IP address"?
The following function will "get IP address":
char *foo(void)
{
return "129.168.32.98";
}
Unless you you can tell us what IP address you want to get, that's as
good a solution as any.
--
Grant Edwards grant.b.edwards Yow! The entire CHINESE
at WOMEN'S VOLLEYBALL TEAM all
Grant Edwards grant.b.edwards Yow! The entire CHINESE
at WOMEN'S VOLLEYBALL TEAM all
We've slightly trimmed the long signature. Click to see the full one.
Site Timeline
- » switching console to fbcon
- — Next thread in » Embedded Linux
-
- » need advice on driver's design
- — Previous thread in » Embedded Linux
-
- » Crosscompiling for ARM: reloc type R_ARM_ABS32 is not supported for PIC - ...
- — Newest thread in » Embedded Linux
-
- » CR1616 en remplacement de CTL1616
- — The site's Newest Thread. Posted in » Electronics (French)
-