Posted to tcl by gps at Thu Mar 12 08:00:41 GMT 2009view raw

  1. #Server
  2. proc get sock {
  3. puts $sock [string repeat "LONG DATA" 2000]
  4. flush $sock
  5. }
  6.  
  7. proc accept {sock args} {
  8. fconfigure $sock -blocking 0
  9. fileevent $sock readable [list get $sock]
  10. }
  11.  
  12. socket -server accept 8888
  13.  
  14. vwait forever
  15.  
  16.  
  17. #Client
  18. set s [socket localhost 8888]
  19. while 1 {
  20. puts $s "SEND"
  21. }
  22.