.
# Program 2, the proxy (the one that exhibits bad behavior):
socket -server proxyit 12344
proc proxyit {chan ca cp} {
fconfigure $chan -blocking 0
set ds [socket -async localhost 12345]
fconfigure $ds -blocking 0
fileevent $ds readable "writeit $ds $chan"
}
proc writeit {ds chan} {
puts stderr "write $ds -> $chan"
set d [read $ds]
if {[eof $ds]} {
puts "eof read $ds"
close $ds
close $chan
} else {
puts stderr "not eof $ds, data = '$d'"
puts -nonewline $chan $d
if {[eof $chan]} {
puts "eof puts $chan"
close $chan
close $ds
}
}
}
vwait forever