Hello, Angelo,
> I tried the multiclient server example provided with Event.pm... works
> great except that if I kill (ctrl-c) or exit the client... the server
> dies/exits as well.
>
> Any thoughts?
unfortunately the example does not check if a connection was closed. It
continues to read, and a SIGPIPE stops the script.
Try to replace the simple
# perform reading
my $line=<$handle>;
by the following:
# perform reading
my $line;
my $readBytes=sysread($handle, $line, 2048);
# all right?
if (defined $readBytes)
{
# connection closed?
unless ($readBytes)
{
# the handle was closed!
warn "[Warn] Connection on channel $channel was closed.\n";
$_[0]->w->cancel;
}
}
else
{
if ($!==EAGAIN)
{
# future read attempts may succeed
}
else
{
# anything is wrong here
warn "[Warn] Anything wrong with channel $channel, closing.\n";
$_[0]->w->cancel;
}
}
This should work better.
Jochen