Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8560451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:16:44+00:00 2026-06-11T16:16:44+00:00

I finally managed to fix ipv6 support in my software. Unfortunately, now it crashes

  • 0

I finally managed to fix ipv6 support in my software. Unfortunately, now it crashes on every ipv4 only machine. Here is the faulty subroutine:

sub init
{
    my ($self, %opts) = @_;

    # server options defaults
    my %defaults = (StartBackground => 0, ServerPort => 3000);

    # set options or use defaults
    map { $self->{$_} = (exists $opts{$_} ? $opts{$_} : $defaults{$_}) }
        keys %defaults;

    $self->{'server'} = HTTP::AppServer::Base->new($self->{'ServerPort'}, Socket::AF_INET6);

    return $self;
}

The problem here is in the second last line:

$self->{'server'} = HTTP::AppServer::Base->new($self->{'ServerPort'}, Socket::AF_INET6);

As on ipv4 only machine it dies complaining about a not supported address family (which is the second parameter passed to the new function).

Basically, what I need to do is:

if (it_supports_ipv6()) {
    $self->{'server'} = HTTP::AppServer::Base->new($self->{'ServerPort'}, Socket::AF_INET6);
}
else {
    $self->{'server'} = HTTP::AppServer::Base->new($self->{'ServerPort'});
}

But how to implement a function like it_supports_ipv6()?

I tried with eval with the following syntax, but it doesn’t work:

my $ipv6_success = eval { $self->{'server'} = HTTP::AppServer::Base->new($self->{'ServerPort'}, Socket::AF_INET6); };
if (!defined($ipv6_success)) {
    $self->{'server'} = HTTP::AppServer::Base->new($self->{'ServerPort'});
}

The logic is that I’ve read in eval doc that it returns undef if the expression causes the program to die.

I’m working on a Linux machine.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T16:16:45+00:00Added an answer on June 11, 2026 at 4:16 pm

    Don’t trust the has_ipv6() function in Paranoid::Network::Socket. It returns false positive as it just checks if Perl supports it, but this isn’t enough at all (the system, as example, could lack ipv6 kernel module loaded).

    I ended up with the following function and it seems to work fine.

    use IO::Socket::IP;
    
    sub supports_ipv6 {
        my $has_ipv6;
    
        eval {
            $has_ipv6 = IO::Socket::IP->new (
                Domain => PF_INET6,
                LocalHost => '::1',
                Listen => 1 ) or die;
        };
    
        if ($@) {
            return 0;
        }
        else {
            return 1;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Finally I managed to get pylucene working on my windows7 machine, Which raised a
I finally managed to get LuaJava to build on OSX and now I am
After 3 hours or so, I've finally managed to fix a memory leak in
I finally managed to install numpy, but it seems to only work in python2.6
I finally managed to connect VBA and a telnet-like terminal. Now I need to
I finally managed to obfuscate my Android application, now I want to test it
I've finally managed to publish my first app on the Android Market. Unfortunately, when
Now I have finally managed to create a fullscreen window via http://cocoadevcentral.com/articles/000028.php Brilliant tutorial.
I have finally managed to get javan-whenever gem working on my site5 server, and
After many hours of research and tinkering, I've finally managed to get backbone.js routes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.