Posted to tcl by sbron at Sun Nov 11 12:46:02 GMT 2007view raw

  1. #!/usr/bin/tclsh
  2.  
  3. set sock [socket localhost 8765]
  4. fileevent $sock readable [list process $sock]
  5.  
  6. proc process {f} {
  7. if {[eof $f]} {
  8. close $f
  9. exit
  10. } elseif {[gets $f line]} {
  11. foreach n {code repeat button remote} v $line {
  12. puts "$n: $v"
  13. }
  14. puts ""
  15. }
  16. }
  17.  
  18. vwait forever
  19.  
  20.  

Comments

Posted by sbron at Sun Nov 11 12:47:54 GMT 2007 [text] [code]

Make that: } elseif {[gets $f line] != -1} {