Detecting EOF in a on_read for AnyEvent::Handle

Rob Hoelz rob at hoelz.ro
Sun Dec 11 19:55:19 CET 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Have you tried $hdl->on_eof?

- -Rob

On Dec 11, 2011, at 12:52 PM, Marios Titas wrote:

> Consider the following scenario: an AnyEvent::Handle object receives
> EOF at a moment when the read queue is empty but an on_read callback
> has been specified. As a result, the on_read callback will then be
> called one last time where it will have a last chance to "consume" all
> data from the read buffer. If it doesn't do that then an error will be
> triggered. My question is, is there a way for this callback to know
> that it has been called because an EOF and not because of new data?
> This is useful when you want to do some parsing of the read buffer
> which depends on whether an EOF has been reached or not. The same
> situation can happen with push_read (the typeless version).
> 
> Right now it is possible to check that by looking at $handle->{_eof}
> but of course this is problematic as it is not documented.
> 
> _______________________________________________
> anyevent mailing list
> anyevent at lists.schmorp.de
> http://lists.schmorp.de/mailman/listinfo/anyevent
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)

iEYEARECAAYFAk7k/JcACgkQUoGaR6SGEarBtQCbBb6/6+7ySPdAcQUGSnhSkIKA
8ocAniSLB6jazLQ7kCKxL2fmqzhyXqIb
=N2Y1
-----END PGP SIGNATURE-----



More information about the anyevent mailing list