This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
Re: Finding Out My Own IP-Address
- To: Oliver Copp <lyger at fh-landshut dot de>, gnu-win32 at cygnus dot com
- Subject: Re: Finding Out My Own IP-Address
- From: "Nicholas R LeRoy" <nleroy at norland dot com>
- Date: Thu, 7 May 1998 08:46:11 -0500
- References: <199805062058.NAA06618@cygnus.com>
On May 6, 10:55pm, Oliver Copp wrote:
> Subject: Finding Out My Own IP-Address
> Hi !
>
> Is there a function which allows me to find out my current IP address ?
>
> My best guess was to use gethostbyname("localhost") but that always returns
> 127.0.0.1.
>
> When I dial in to my provider via NT-RAS, I'm assigned a dynamic IP address -
> which is what I'm trying to find out.
It's been a while since I've done socket programming, but if I remember
correctly, what you want to do is use "gethostname" to get youre host's
real name, and then "gethostbyname" to look up the IP. Note that if you
have more than one interface, it becomes more complicated. Probably irrelevant
in the WinDoze world, though.
-Nick
--
+-------------------------------+--------------------------------------------+
| /`--_ Nicholas R LeRoy | In a world without fences, Who needs Gates?|
|{ }/ Norland Corporation | ---- Experience Linux! ---- |
| \ * / W6340 Hackbarth Rd | http://www.linux.org | http://www.ssc.com |
| |___| Fort Atkinson, WI 53538 +--------------------------------------------+
| nick.leroy@norland.com | #include <disclaimer.h> |
|http://www.norland.com/~nleroy | These are my own ideas, not my employer's. |
+----------------------------------------------------------------------------+
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".