Greetings monks,
This is a followup on my earlier query:
syswrite and closed sockets. Although the excellent guide by fellow monks solved many of the problems, however I hit upon one more issue and request your insights.
I have the following piece of code, which uses IO::Socket::INET to open a blocking socket against a messaging server and attempts to write a text:
use IO::Socket::INET;
use Carp;
my $socket = IO::Socket::INET->new(
PeerAddr=> $host,
PeerPort=> $port,
Proto=> "tcp",
Blocking => 1 ) ;
for(1..100){
print $_ . "..";
sleep(2);
eval{
$output = $socket->syswrite($string);
};
croak "Could not syswrite: $@\n" if(!$output or $@);
print "done\n";
}
While this code is running, I shutdown the message service. This causes the script to exit, after a couple of iteration. I was expecting to see the croak message, however the script just exits.
I tried to execute this script via Komodo IDE, and in the IDE output window I could see the croak message. Besides if I modified the error handling part to, lets say, write a message to a file and follow the process:
- via a shell: no output and nor the file is being created
- via Komodo: I see the croak message and the file is being created
My questions:
- What is causing this behaviour ?
- if syswrite does a exit, how can I handle it in a OO context ? (I know we can handle exits via WIFEXITED, but only if executed as a child process)