Posted to tcl by apn at Fri Apr 27 15:10:49 GMT 2018view raw
- The following code hangs until the remote end closes the connection and times out.
- set so [socket -async www.example.com 80]
- fconfigure $so -buffering line -translation crlf -blocking 0
- puts $so "GET / HTTP/1.1"
- puts $so "Host: www.example.com"
- puts $so ""
- fconfigure $so -blocking 1
- gets $so; # Hangs here
- If the fconfigure -blocking 1 line is removed, it works correctly (although a couple of gets invocations may be necessary to get the results)
Comments
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