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:

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, ); }

Hi,

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:

#!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"; }
When I run the above code sample, it produces:
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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.