Finding Out My Own IP-Address

Nicholas R LeRoy nleroy@norland.com
Thu May 7 18:58:00 GMT 1998


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".



More information about the Cygwin mailing list