Why doesn't on_eof get called on this example?
Konstantin A. Pustovalov
konstantin.pustovalov at gmail.com
Tue Jun 24 08:54:21 CEST 2014
On 24.06.2014 00:47, Alexander Karelas wrote:
> http://stackoverflow.com/questions/24373840/why-isnt-on-eof-called-in-this-anyeventhandle-example
>
>
> I notice that when there is on on_read function, then on_eof doesn't
> get called when the telnet client connects and immediately disconnects.
>
> However when an $hdl->on_read(sub{ say "READ!" }); statement is
> executed, then the on_eof event gets called even though the on_read
> event never gets called.
>
> So why is on_read needed for on_eof, if it doesn't get executed?
> Should this be in the documentation? Maybe this could be classified as
> a bug?
You should read
http://search.cpan.org/~mlehmann/AnyEvent-7.07/lib/AnyEvent/Handle.pm#NONFREQUENTLY_ASKED_QUESTIONS
Also, manual says about read queue:
> It can be used in two ways, the "simple" way, using only|on_read|and
the "complex" way, using a queue.
I think that when there is no on_read handler and read queue is empty (
there is no outstanding push_read requests ) AE::Handle is unable to
decide whether to call on_eof or on_error. You should be able to
construct AE::handle with no on_read and empty queue. Then make
push_read( line => ) request and get on_error called.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/anyevent/attachments/20140624/2d824e25/attachment.html>
More information about the anyevent
mailing list