Posted to tcl by aspect at Thu May 28 11:02:16 GMT 2015view raw

  1. # on FreeBSD-10.1, this test fails (no error from puts) about 50% of the time
  2. # on Debian jessie it seems to succeed every time
  3. # inspired by http://core.tcl.tk/tcllib/tktview?name=ced089d5fe
  4.  
  5. set PORT 37465
  6.  
  7. set s [socket -server accept $PORT]
  8. proc accept {chan args} {
  9. puts "New connection $args"
  10. puts "Closing $chan"
  11. close $chan
  12. }
  13.  
  14. set sk [socket localhost $PORT]
  15. fconfigure $sk -buffering none
  16.  
  17. update
  18.  
  19. try {
  20. puts $sk "boom"
  21. update
  22. } on error {e eo} {
  23. puts "PASS: got expected error"
  24. } on ok {} {
  25. puts "FAIL: writing to unbuffering, disconnected socket succeeds!"
  26. }