<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <br>
    <blockquote cite="mid:53A95170.7010706@gmail.com" type="cite">
      <blockquote cite="mid:53A9209D.6060809@gmail.com" type="cite"> <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>
      </blockquote>
      <br>
      <br>
      Why is AE::Handle unable to decide? Why couldn't it just call
      on_eof in that case?<br>
    </blockquote>
    <meta http-equiv="content-type" content="text/html;
      charset=ISO-8859-1">
    <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;"><br>
      man clearly says:<br>
      > Note that, unlike requests in the read queue, an<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>callback
      doesn't mean you<span class="Apple-converted-space"> </span></span><i
      style="color: rgb(0, 0, 0); font-family: arial, sans-serif;
      font-size: medium; 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);">require</i><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>some
      data: if there is an EOF and there are outstanding read requests
      then an error will be flagged. With an<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>callback,
      the<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_eof</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>callback
      will be invoked.<br>
      <br>
      In other words, say, you are writing script which parses CSV file.
      The format is line-oriented. Script reading header line might be
      something like:<br>
      <br>
      my $cv = AE::cv;<br>
      my $h = AnyEvent::Handle->new(<br>
          fh => $fh,<br>
          on_error => sub {<br>
              my( $hdl, undef, $msg ) = @_;<br>
              $hdl->destroy;<br>
              $cv->croak( $msg );<br>
          }<br>
      );<br>
      $h->push_read( line => sub {<br>
          my( undef, $header ) = @_;<br>
          eval { parser->parse( $header ) };<br>
          if( $@ ne '' ) {<br>
              $cv->croak( "Parse error: $@" )<br>
          } else {<br>
              $cv->send;<br>
          }<br>
      <br>
      });<br>
      $cv->recv;<br>
      <br>
      ie, when script expects header line from the file, EOF before
      first \n is actually an error and is handled as an error in this
      code, on_eof should not be called.<br>
    </span>
  </body>
</html>