Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 82921ec543fa2c36d030bf3a49ca50ef0088425d
Ticket: 1995063fffffffffffffffffffffffffffffffff
Doc: example in fileevent manpage is bad.
User & Date: flatworm on 2008-06-16 22:32:22
Changes

  1. icomment:
    Logged In: YES 
    user_id=1350198
    Originator: NO
    
    While the statement regarding EOF made by Donal and Alexander is correct, since [fileevent readable] handler is *necessarily* called on a non-blocking channel when a EOF condition is encountered, the whole problem just has no meaning: when I have
    
    proc Read chan {
      if {[eof $chan]} {
        close $chan
        ...
      } else {
        set data [read $chan]
      }
    }
    ...
    fileevent $chan readable [list Read $chan]
    
    in my code, [Read] will be called on EOF anyway. Just the event subsystem will make one extra invocation of the callback script.
    
    For instance, reading from a file of length 0 using a proc similar to that shown above will result in two invocations of the proc -- one for [read] which will return an empty string and one resulting from hitting EOF.
    
    So in fact it's not a big deal where checking for EOF is performed.
    
    
  2. login: "flatworm"
  3. mimetype: "text/plain"
  4. username: "flatworm"