Subject: | Filehandle watchers shut down after a single event? |
The following server only accepts one connection. The select_read() for
the listening socket fires only once. POE::Loop::Glib's filehandle
callbacks return 0, which prevents them from firing a second time.
Changing the callbacks to return 1 fixes this server.
use strict;
use warnings;
sub POE::Kernel::ASSERT_DEFAULT () { 1 }
sub POE::Kernel::TRACE_FILES () { 1 }
use Glib;
use POE qw/Loop::Glib/;
use POE::Component::Server::TCP;
POE::Component::Server::TCP->new(
Alias => "sum_server",
Address => "localhost",
Port => 12345,
Started => sub {
print("Started\n");
},
ClientConnected => sub {
print("Client Connected\n");
},
ClientInput => sub {
my ($heap, $data) = @_[HEAP, ARG0];
print("Received input: $data\n");
$heap->{client}->put("Poing!");
$_[KERNEL]->yield('shutdown');
},
ClientDisconnected => sub {
my $kernel = $_[KERNEL];
print("Client disconnected\n");
},
);
print "Using loop: " . $poe_kernel->poe_kernel_loop() . "\n";
$poe_kernel->run();