Problem with AnyEvent::Handle and on_eof

Pedro Melo melo at simplicidade.org
Sat Mar 7 19:26:50 CET 2009


Hi,

Sorry to reply to myself, forgot to mention that if we replace on_eof  
with on_error it works fine.

Best regards,

On Mar 7, 2009, at 6:25 PM, Pedro Melo wrote:

> Hi,
>
> I'm trying to understand how on_eof works in AnyEvent::Handle. I  
> copied the example in the synopsis and added a couple or print  
> statements. The code I'm using to test this is at the end of the  
> message.
>
> On both Linux (CentOS 4.6 Final) and Mac OS X 10.5.6, I get a  
> strange behaviour. If I do this:
>
> touch aa
> ./ae_handle_example.pl < a
>
> the script never ends. I assumed that the on_eof would be triggered  
> and the $cv->send executed, but it never is.
>
> What am I missing? The MODEL I'm using is AnyEvent::Impl::EV.
>
> Thanks in advance,
>
>
> ---- 8< ----
> use AnyEvent;
> use AnyEvent::Handle;
>
> my $cv = AnyEvent->condvar;
> print "Using $AnyEvent::MODEL\n";
>
> my $handle =
>   AnyEvent::Handle->new (
>      fh => \*STDIN,
>      on_eof => sub {
>         print "!! EOF\n";
>         $cv->send;
>      },
>   );
>
> # send some request line
> $handle->push_write ("getinfo\015\012");
>
> # read the response line
> $handle->push_read (line => sub {
>   my ($handle, $line) = @_;
>   warn "read line <$line>\n";
>   $cv->send;
> });
>
> $cv->recv;
> ---- 8< ----
>
> -- 
> Pedro Melo
> Blog: http://www.simplicidade.org/notes/
> XMPP ID: melo at simplicidade.org
> Use XMPP!
>
>

-- 
Pedro Melo
Blog: http://www.simplicidade.org/notes/
XMPP ID: melo at simplicidade.org
Use XMPP!





More information about the libev mailing list