Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: How to handle Net::Address::IP::Local'->public when we are not connected to internet (INADDR_ANY)

by Anonymous Monk
on Jan 19, 2015 at 17:28 UTC ( [id://1113788]=note: print w/replies, xml ) Need Help??


in reply to Re: How to handle Net::Address::IP::Local'->public when we are not connected to internet (INADDR_ANY)
in thread How to handle Net::Address::IP::Local'->public when we are not connected to internet

I tried the code below but still it gives error :
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; } }
error is :
Unable to create UDP socket: A socket operation was attempted to an un +reachab network. at C:/Perl/site/lib/Net/Address/IP/Local.pm line 166.

Replies are listed 'Best First'.
Re^3: How to handle Net::Address::IP::Local'->public when we are not connected to internet (INADDR_ANY)
by Laurent_R (Canon) on Jan 19, 2015 at 18:54 UTC
    In the post you included in your other thread on the same subject, the output you gave showed the socket error and then the printed IP address, so that it appears that this part of your code is working properly, your program non longer dies on the error and is able to print the IP address after the socket open failure.

    Je suis Charlie.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1113788]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (6)
As of 2024-03-28 15:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found