sch has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: IO::Socket hanging during requests
by fokat (Deacon) on Oct 20, 2002 at 01:29 UTC | |
|
Re: IO::Socket hanging during requests
by sch (Pilgrim) on Oct 20, 2002 at 05:26 UTC | |
by Ryszard (Priest) on Oct 20, 2002 at 10:09 UTC | |
by sch (Pilgrim) on Oct 20, 2002 at 17:06 UTC | |
|
Re: IO::Socket hanging during requests
by sch (Pilgrim) on Oct 20, 2002 at 00:18 UTC |