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)
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.