in reply to Re^3: Why 'Net::Address::IP::Local'->public do not return IP address
in thread Why 'Net::Address::IP::Local'->public do not return IP address
And i got error again like this :use strict; use warnings; use Net::Address::IP::Local; print ReturnIpAddress(); sub ReturnIpAddress { my $address; select STDOUT; eval{ $address = 'Net::Address::IP::Local'->public ; ## Rece +iving the current IP ## }; if ($@) { print "$@"; return '192.80.160.16'; ##If No IP address received th +en return a static IP of order "192....." } else { return $address; } }
Any solution. Please note that this problem occurs when i disconects the internet and then execute the code (i am under such situation). Any other way to handle this problem ? (To test the code you will need to resatrt the PC and with internet turnoff otherwise it still keeps store the IP of the time of connection and print the IP but when we restart PC then we will not have that previous IP)C:\shekhar_Axestrack_Intern\WindowCreation>ccc.pl Unable to create UDP socket: A socket operation was attempted to an un +reachable network. at C:/Perl/site/lib/Net/Address/IP/Local.pm line 166. 192.80.160.16
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Why 'Net::Address::IP::Local'->public do not return IP address
by Laurent_R (Canon) on Jan 19, 2015 at 18:39 UTC |