Hi all, hoping someone could cast an eye over this and let me know if you have any thoughts as to whats going on.

In the following piece of code %servers is a hash where the key is an ip address and the value is a port (I don't think it's particularly important to the problem at hand, but the servers are opennap servers).I'm trying to setup connections to these servers using IO::Socket and have been seeing something strange - when the code loops through the %servers hash, every couple of iterations it hangs for a minute or so. Can anyone suggest why this might be happening. The code is as follows:

foreach (keys(%servers)) { print "Connecting to $_ :: $servers{$_}: "; my $socket; $socket = IO::Socket::INET->new( PeerAddr => $_, PeerPort => $servers{$_}, Proto => "tcp", Reuse => 1, Type => SOCK_STREAM); if (! defined ($socket)) { print "$@\n"; next; } print "Connected\n"; close $socket; $socket->DESTROY; print "..\n"; }

When it runs I get something like:

Connecting to 24.164.137.84 :: 3456: IO::Socket::INET: connect: Connec +tion refused Connecting to 62.163.22.155 :: 4200: Connected .. (hangs here) Connecting to 80.117.254.113 :: 8888: IO::Socket::INET: connect: Conne +ction refused Connecting to 62.226.24.21 :: 8888: IO::Socket::INET: connect: Connect +ion refused (hangs here) Connecting to 80.134.24.185 :: 8888: IO::Socket::INET: connect: Connec +tion refused Connecting to 217.84.215.47 :: 7777: IO::Socket::INET: connect: Connec +tion refused Connecting to 80.133.122.25 :: 7777: IO::Socket::INET: connect: Connec +tion refused Connecting to 213.84.39.165 :: 4567: IO::Socket::INET: connect: Connec +tion refused Connecting to 24.156.72.65 :: 513: IO::Socket::INET: connect: Connecti +on refused (hangs here)

But today you took me walking, Through a land that we have lost,
While our children sit at websites, With no access to the cost


In reply to IO::Socket hanging during requests by sch

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.