in reply to EV::io and Sockets
so there must be sth. wrong with the 2nd watcher:
The one thing wrong with it is - there's no loop for it.
sub handle_incoming { my $w=shift; my $h=$w->fh; my $client=$h->accept or die; print "socket connection in...\n"; my $w = EV::io $client, EV::READ, \&handle_client; EV::loop; }
The second thing wrong is <$client> - that should be <$h>. Use strict. Use strict!
Then, in handle_client, the handler should unregister itself if the read result is undef; otherwise it will loop forever:
sub handle_client { my $w=shift; my $h=$w->fh; $in=<$h>; $w->DESTROY unless defined $in; print "in=$in\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: EV::io and Sockets
by Walchy (Initiate) on Jan 04, 2009 at 04:10 UTC |