-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Hello all!
I'm creating some sockets to a remote server and from time to time, the
sockets get "frozen".
I'm creating the socket as:
$socket = IO::Socket::INET->new (
PeerAddr => $server,
PeerPort => $port,
Blocking => 1,
Proto => 'tcp',
Timeout => 20, #connection timeout
) or die "Error: Failed to
connect : $!\n";
So far so good, but when i try to make a first read, the read hangs
(always on the first read - If the first read is successfull all the
other reads will succeed). No error whatsoever (the connection doesn't
even drop!).
I'm reading the socket as:
sub _read_from_socket{
my ($socket) = @_;
my ($output, $buffer) = ('', '');
while(1){
my $status = $socket->read($buffer, 1);
die "Error: $!" if(!defined $status);
$output .= $buffer;
last if $output =~ /\r\n$|^\z/;
}
return $output;
}
The same happens even with a sysread (both on windows and linux
platforms). This hanging doesn't happen everytime, it's like 1 in 6
tries.
If i check with netstat i see the connection with state ESTABLISHED.
Do you guys know what's going on?
Regards,
David Santiago
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQEcBAEBCAAGBQJWG+bCAAoJEJ/OLjwuDYzKX3wIAKT0pH1gdcUMxmgGrN6v5vbJ
MVvNx85HJ9Z83LEe8hewsxVLLxcYVgVCIm/VAdRuDKREZmnL7xdraaHmu3a2wHzG
/yNedRGs/CWJdZB0jt+o7Y3RbH9dFo9YMSpRugUHrQPbhe4fY5PbWws7RPleR2fv
AXpKRd3wx4zxdzbrbVieXtLNCgqRvEEFJ9Jpq0SYXQ9Tv+E7BoJ4+u2Zx4jfQMfv
54YOx6lEMiMRLCUdDe+bft26J6OoYWZCk88Dk92VurCdvIsSXKsqFeB84B3B1lva
J7/BJQdFsbzTsSy7egdbiQUKApRR1uhW6IeClEkhbFzrfpF/lKJGZXU022PrJTE=
=TeGg
-----END PGP SIGNATURE-----