Posted to tcl by apn at Fri Apr 27 15:10:49 GMT 2018view raw

  1. The following code hangs until the remote end closes the connection and times out.
  3. set so [socket -async 80]
  4. fconfigure $so -buffering line -translation crlf -blocking 0
  5. puts $so "GET / HTTP/1.1"
  6. puts $so "Host:"
  7. puts $so ""
  8. fconfigure $so -blocking 1
  9. gets $so; # Hangs here
  11. If the fconfigure -blocking 1 line is removed, it works correctly (although a couple of gets invocations may be necessary to get the results)


Posted by apn at Fri Apr 27 15:13:00 GMT 2018 [text] [code]

Note: code must be run as a script, not typed at the command line