daphnaw has asked for the wisdom of the Perl Monks concerning the following question:

Hi, We have been adding support for IPV6 in our application. We have Perl scripts executing XML-RPC client commands against a Java-based XML-RPC server. Trying to connect to an IPV6 address fails with "Bad hostname":
my $cli = RPC::XML::Client->new("http://localhost6:$port/RPC2"); my $cli_client = RPC::XML::request->new('AnaXmlRpcHandler.execute', ,R +PC::XML::array->new(map {RPC::XML::string->new($_)} @arr));
Result:

Can't locate object method "value" via package "RPC::XML::Client::request: HTTP server error: Can't connect to localhost6:8099 (Bad hostname 'localhost6')" (perhaps you forgot to load "RPC::XML::Client::request: HTTP server error: Can't connect to localhost6:8099 (Bad hostname 'localhost6')"?)

The following attempt also fails:
my $cli = RPC::XML::Client->new("http://[2001:db8:c18:2:250:56ff:fead: +2d92]:$port/RPC2"); my $cli_client = RPC::XML::request->new('AnaXmlRpcHandler.execute', ,R +PC::XML::array->new(map {RPC::XML::string->new($_)} @arr));

Can't locate object method "value" via package "RPC::XML::Client::request: HTTP server error: Can't connect to 2001:db8:c18:2:250:56ff:fead:2d92:8099 (Bad hostname '2001:db8:c18:2:250:56ff:fead:2d92')" (perhaps you forgot to load "RPC::XML::Client::request: HTTP server error: Can't connect to 2001:db8:c18:2:250:56ff:fead:2d92:8099 (Bad hostname '2001:db8:c18:2:250:56ff:fead:2d92')"?)

I've read the "State of Perl", and would like to know whether upgrading some of the dependant modules will do, and if not, what other options are available?

Replies are listed 'Best First'.
Re: IPv6 support for XML-RPC modules
by Khen1950fx (Canon) on Mar 27, 2011 at 10:12 UTC
    Net::INET6Glue might help. It works for FTP, SMTP, and LWP. For example, your script would start:
    #!/usr/bin/perl use Net::INET6Glue; require RPC::XML; require RPC::XML::Client;
    It works by replacing IO::Socket::INET with IO::Socket::INET6, aka "hot-patching". Make sure that you have IO::Socket::INET6 installed.
      I've installed Net::INET6Glue, but still fail:
      use warnings; use Net::INET6Glue::INET_is_INET6; require RPC::XML; require McClient; my $port = 8011; my @arr = @ARGV; my $host = "::1"; my $cli = RPC::XML::Client->new("http://[$host]:$port/RPC2"); my $cli_client = RPC::XML::request->new('AnaXmlRpcHandler.execute', ,R +PC::XML::array->new(map {RPC::XML::string->new($_)} @arr));

      Now the error is different:

      Can't locate object method "value" via package "RPC::XML::Client::request: HTTP server error: Can't connect to ::1:localhost:80 (sock_info: Bad service '80')" (perhaps you forgot to load "RPC::XML::Client::request: HTTP server error: Can't connect to ::1:localhost:80 (sock_info: Bad service '80')"?)

      It seems the localhost is concateneated to ::1 and the port is cut (8011 -> 80). am I mis-using it ?
        It may be that localhost is either misconfigured, or the url is wrong. Now you'll need to do some error checking. I put a test script together to get you started.
        #!/usr/bin/perl use strict; use warnings; use Net::INET6Glue; require RPC::XML; require RPC::XML::Client; my $server_url = 'http://test.xmlrpc.wordtracker.com'; my $cli = RPC::XML::Client->new($server_url); my $res = $cli->send_request( 'ping', 'guest' ); if ( ${$res} == 1 ) { print "Successfully pinged guest account", "\n"; exit 0; } else { print "There were problems...\n"; exit 0; }
        Experiment with it. If you continue to have problems, post again.