This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Finding Out My Own IP-Address


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]