Posted to tcl by kbk at Sat Feb 19 19:41:54 GMT 2011view raw

  1. proc irc_recv {chan} {
  2. if {[catch {read $chan} data]} {
  3. # ... the read got an error, $data has the error message
  4. } elseif {[string length $data > 0]} {
  5. # ... the read worked, $data has the data
  6. } elseif {[eof $chan]} {
  7. # ... end of file
  8. } elseif {[fblocked $chan]} {
  9. # ... The read is blocked. This can happen with gets, but
  10. # shouldn't happen with read.
  11. return
  12. } else {
  13. # WTF? This case shouldn't be possible.
  14. }
  15. }