Posted to tcl by dgood` at Tue Oct 29 18:58:14 GMT 2013view raw
- proc SocketReader {chan} {
- global G
- puts [info level 0]
- # If errors occur while reading channel, close and cleanup the channel
- if {[catch {
- set data [read $chan]
- set eof [eof $chan]
- } err]} {
- # Unexpected channel error
- log error "Socket $chan error: $err"
- catch {close $chan}
- set G(Socket.Chan) {}
- return
- }
- if {$eof == 1} {
- log debug "Got EOF on Socket $chan, closing chan"
- catch {close $chan}
- set G(Socket.Chan) {}
- return
- }
- log debug "Got data from Socket $chan: '$data'"
- }