<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 24.06.2014 00:47, Alexander Karelas
      wrote:<br>
    </div>
    <blockquote cite="mid:53A89247.5080201@gmail.com" type="cite"><a class="moz-txt-link-freetext" href="http://stackoverflow.com/questions/24373840/why-isnt-on-eof-called-in-this-anyeventhandle-example">http://stackoverflow.com/questions/24373840/why-isnt-on-eof-called-in-this-anyeventhandle-example</a>
      <br>
      <br>
      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.
      <br>
      <br>
      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.
      <br>
      <br>
      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?
      <br>
    </blockquote>
    <br>
    You should read
<a class="moz-txt-link-freetext" href="http://search.cpan.org/~mlehmann/AnyEvent-7.07/lib/AnyEvent/Handle.pm#NONFREQUENTLY_ASKED_QUESTIONS">http://search.cpan.org/~mlehmann/AnyEvent-7.07/lib/AnyEvent/Handle.pm#NONFREQUENTLY_ASKED_QUESTIONS</a><br>
    <br>
    Also, manual says about read queue:<br>
    <br>
    > <span style="color: rgb(0, 0, 0); font-family: arial,
      sans-serif; font-size: medium; font-style: normal; font-variant:
      normal; font-weight: normal; letter-spacing: normal; line-height:
      normal; orphans: auto; text-align: start; text-indent: 0px;
      text-transform: none; white-space: normal; widows: auto;
      word-spacing: 0px; -webkit-text-stroke-width: 0px;
      background-color: rgb(255, 255, 255); display: inline !important;
      float: none;">It can be used in two ways, the "simple" way, using
      only<span class="Apple-converted-space"> </span></span><code
      style="color: rgb(0, 0, 0); font-style: normal; font-variant:
      normal; font-weight: normal; letter-spacing: normal; line-height:
      normal; orphans: auto; text-align: start; text-indent: 0px;
      text-transform: none; white-space: normal; widows: auto;
      word-spacing: 0px; -webkit-text-stroke-width: 0px;
      background-color: rgb(255, 255, 255);">on_read</code><span
      style="color: rgb(0, 0, 0); font-family: arial, sans-serif;
      font-size: medium; font-style: normal; font-variant: normal;
      font-weight: normal; letter-spacing: normal; line-height: normal;
      orphans: auto; text-align: start; text-indent: 0px;
      text-transform: none; white-space: normal; widows: auto;
      word-spacing: 0px; -webkit-text-stroke-width: 0px;
      background-color: rgb(255, 255, 255); display: inline !important;
      float: none;"><span class="Apple-converted-space"> </span>and the
      "complex" way, using a queue.</span><br>
    <br>
    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.<br>
    <br>
    <br>
    <br>
    <span style="color: rgb(0, 0, 0); font-family: arial, sans-serif;
      font-size: medium; font-style: normal; font-variant: normal;
      font-weight: normal; letter-spacing: normal; line-height: normal;
      orphans: auto; text-align: start; text-indent: 0px;
      text-transform: none; white-space: normal; widows: auto;
      word-spacing: 0px; -webkit-text-stroke-width: 0px;
      background-color: rgb(255, 255, 255); display: inline !important;
      float: none;"></span>
  </body>
</html>