Posted to tcl by dgood` at Tue Oct 29 18:58:14 GMT 2013view raw

  1. proc SocketReader {chan} {
  2. global G
  3.  
  4. puts [info level 0]
  5. # If errors occur while reading channel, close and cleanup the channel
  6. if {[catch {
  7. set data [read $chan]
  8. set eof [eof $chan]
  9. } err]} {
  10. # Unexpected channel error
  11. log error "Socket $chan error: $err"
  12. catch {close $chan}
  13. set G(Socket.Chan) {}
  14. return
  15. }
  16.  
  17. if {$eof == 1} {
  18. log debug "Got EOF on Socket $chan, closing chan"
  19. catch {close $chan}
  20. set G(Socket.Chan) {}
  21. return
  22. }
  23.  
  24. log debug "Got data from Socket $chan: '$data'"
  25. }