Detecting EOF in a on_read for AnyEvent::Handle

Marc Lehmann schmorp at schmorp.de
Mon Dec 12 13:28:52 CET 2011


On Sun, Dec 11, 2011 at 01:52:43PM -0500, Marios Titas <redneb8888 at gmail.com> wrote:
> 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

When would this be useful? Consider that TCP itself doesn't offer this, so
applications requiring it should be rare.

> Right now it is possible to check that by looking at $handle->{_eof}
> but of course this is problematic as it is not documented.

Sockets don't work that way though - the OS doesn't tell you that an EOF
has happened *before* reading all the outstanding data. Checking _eof is
not just undocumented, but also unreliable (it might not be set).

If you really think it is useful, please state a convincing use case, and
how you think it should behave.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\



More information about the anyevent mailing list