UPDATE:
I'd still like to solve this problem, but I have a work-around which I figured I'd post, in case others are helped by this. Taking VinsWorldcom's advice, I modified the Address.pm file to not call Socket. Instead, it calls the ip_to_int function in IP::Tools. Here's the modified sub in Address.pm:
Hi,sub new_from_string { my $class = shift; my %p = @_; my $str = delete $p{string}; my $version = delete $p{version}; my $ip = $str; use IP::Tools; # if ( defined $str && inet_pton( AF_INET, $str ) ) { if ( defined $str ) { $version ||= 4; $str = '::' . $str if $version == 6; } else { $version ||= 6; _validate_ip_string( $str, $version ); } return $class->new( _integer => IP::Tools::ip_to_int($ip), # _integer => _string_address_to_integer( $str, $version ), version => $version, %p, ); }
I have GeoIP2 running great on Linux, but I can't get it running under *Windows Perl due to errors related to the 'inet_pton' function.
The GeoIP2 module calls MaxMind::DB::Reader (documentation forthcoming), which in turn calls Net::Works::Address, which in turn calls Socket::inet_pton. Once it hits that function, it craps out. Here's some example code:
When I run the above code sample, it produces:#!c:/apps/strawberry/perl/bin/perl.exe use strict; use warnings; use Net::Works::Address; my $addr = '1.2.3.4'; my $ip = Net::Works::Address->new_from_string( string => $addr); for(qw/as_string as_integer as_binary as_bit_string version mask_lengt +h/){ print $_,": ",$ip->$_(),"\n"; }
Socket::inet_pton not implemented on this architecture at C:/apps/stra +wberry/perl/site/lib/Net/Works/Util.pm line 42.
I've found this Strawberry Perl bug report for it, but it doesn't help, as far as I can see.
From what I can gather at this Stackoverflow discussion, 'inet_pton' was not added to Windows until Vista came around, but there exists in Windows XP a function called WWSAAddressToString() which could be implemented to emulate it. I would not know where to start with that, plus I would prefer a pure Perl solution.
Does anyone have any ideas or pointers?
* Strawberry Perl 5.16.3.1 64-bit on Windows XP Pro, SP2, 64-bit
In reply to inet_pton on Windows Perl by atreyu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |