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 57759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:44:29+00:00 2026-05-10T17:44:29+00:00

I have a (from what I can tell) perfectly working Linux setup (Ubuntu 8.04)

  • 0

I have a (from what I can tell) perfectly working Linux setup (Ubuntu 8.04) where all tools (nslookup, curl, wget, firefox, etc) are able to resolve addresses. Yet, the following code fails:

$s = new IO::Socket::INET(     PeerAddr => 'stackoverflow.com',     PeerPort => 80,     Proto => 'tcp', );  die 'Error: $!\n' unless $s; 

I verified the following things:

  • Perl is able to resolve addresses with gethostbyname (ie the code below works):

    my $ret = gethostbyname('stackoverflow.com'); print inet_ntoa($ret);

  • The original source code works under Windows

  • This is how it supposed to work (ie. it should resolve hostnames), since LWP tries to use this behavior (in fact I stumbled uppon the problem by trying to debug why LWP wasn’t working for me)
  • Running the script doesn’t emit DNS requests (so it doesn’t even try to resolve the name). Verified with Wireshark
  • 1 1 Answer
  • 5 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. 2026-05-10T17:44:30+00:00Added an answer on May 10, 2026 at 5:44 pm

    From a quick look, the following code from IO::Socket::INET

    sub _get_addr {     my($sock,$addr_str, $multi) = @_;     my @addr;     if ($multi && $addr_str !~ /^\d+(?:\.\d+){3}$/) {         (undef, undef, undef, undef, @addr) = gethostbyname($addr_str);     } else {         my $h = inet_aton($addr_str);         push(@addr, $h) if defined $h;     }     @addr; } 

    suggests (if you look at the caller of this code) the work-around of adding MultiHomed => 1, to your code.

    Without that work-around, the above code appears to try to call inet_aton('hostname.com') using the inet_aton() from Socket.pm. That works for me in both Win32 and Unix, so I guess that is where the breakage lies for you.

    See Socket.xs for the source code of inet_aton:

    void inet_aton(host)     char *  host     CODE:     {         struct in_addr ip_address;         struct hostent * phe;          if (phe = gethostbyname(host)) {             Copy( phe->h_addr, &ip_address, phe->h_length, char );         } else {             ip_address.s_addr = inet_addr(host);         }          ST(0) = sv_newmortal();         if(ip_address.s_addr != INADDR_NONE) {             sv_setpvn( ST(0), (char *)&ip_address, sizeof ip_address );         }     } 

    It appears that the Perl gethostbyname() works better than the C gethostbyname() for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

so from what i can tell, you have to specify artifacts and working directory
i have invoked blackberry calender from my application can anyone tell me how to
I have an app from where I can get the list of all installed
I have a from where you can fill in any combination of your home,
I have a code from where I can get the contacts name in a
I have learned from various tutorial that If a client can reasonably be expected
I have a DataGrid . I have DataGridDragDropTarget from November Toolkit. I now can
com/jniwrapper/win32/ie/WebBrowser class not found. From where can I download jniWrapper library. I have downloaded
I have a list of videos that a user can select from to watch.
I have a engine style Rails plugin from which I can create a gem

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.