Link to home
Start Free TrialLog in
Avatar of tcolson
tcolson

asked on

TCP/IP: Determine IP# for PPP interface on WIN32

The following code will provide you with the IP# on the primary Ethernet Card in Win95. However, it won't let you find out your current PPP IP#.

Extra Special points for anyone who can tell me how to find ALL IP#'s on the machine (ex. 2 PPP connects + 2 ethernet cards) - using PERL not winipcfg :-)

Thanks,
Timothy


use Sys::Hostname;
print "start of an IP Poster in PERL\n";
print join '.', unpack 'C4', gethostbyname hostname;
print "\n" . hostname;
Avatar of ijduggan
ijduggan

Is it possible for you to just parse the output of the netstat program?

"netstat -n"  returns data on current connections. You could try something like:

my %connections;
open(NETSTAT, "netstat -n |");
while(<NETSTAT>) {


process netstat data


}

Does netstat provide you with enough information to do what you want?

Avatar of tcolson

ASKER

IJDUGGAN wrote:
>Does netstat provide you with enough information
>to do what you want?
Unfortunately no - Netstat provides you with currently active connections on specific ports. So, for example, right now I'm connected to my ISP...and every 5 minutes my email client polls for mail -> during this time:
C:\WINDOWS>netstat
Active Connections
  Proto  Local Address          Foreign Address        State
  TCP    homebrew:1045          popserver.somewhere.com:pop3  TIME_WAIT

However, after this connection has closed:
C:\WINDOWS>netstat
Active Connections
  Proto  Local Address          Foreign Address        State

-> No data. But I am still connected to my ISP...so there must be another way to find the IP#.

Perhaps the answer lies in finding out where WINIPCFG gets its information from??? This stuff must be in the registry somewhere, eh?

Thanks,
TLC

ASKER CERTIFIED SOLUTION
Avatar of b2pi
b2pi
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial