Posted to tcl by crshults at Mon Jun 15 18:26:04 GMT 2015view raw

  1. set port 9000
  2.  
  3. proc read_data {sock} {
  4. puts [read $sock]
  5. if {[chan eof $sock]} {
  6. puts "chan is eof"
  7. chan event $sock readable {}
  8. chan close $sock
  9. }
  10. }
  11.  
  12. proc uniform {str} {
  13. global port
  14. set sock [socket localhost $port]
  15. chan configure $sock -translation binary -buffering none -blocking no
  16. set msg "RCTL\nBEGIN\n${str}\nEND"
  17. chan event $sock readable "read_data $sock"
  18. chan puts $sock $msg
  19. }
  20.  
  21. uniform "some task"
  22.