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

proc irc_recv {chan} {
    if {[catch {read $chan} data]} {
	# ... the read got an error, $data has the error message
    } elseif {[string length $data > 0]} {
	# ... the read worked, $data has the data
    } elseif {[eof $chan]} {
	# ... end of file
    } elseif {[fblocked $chan]} {
	# ... The read is blocked. This can happen with gets, but
	# shouldn't happen with read.
	return
    } else {
	# WTF?  This case shouldn't be possible.
    }
}