delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/05/08/01:29:29

From: nleroy AT norland DOT com (Nicholas R LeRoy)
Subject: Re: Finding Out My Own IP-Address
8 May 1998 01:29:29 -0700 :
Message-ID: <9805070846.ZM18698.cygnus.gnu-win32@dopey>
References: <lyger AT fh-landshut DOT de>
Mime-Version: 1.0
To: Oliver Copp <lyger AT fh-landshut DOT de>, gnu-win32 AT cygnus DOT 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 DOT leroy AT norland DOT 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 AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019