Artifact
f87bc183f94feda187c0e44e214bfa10b2f3ba9b:
Attachment "zlibtest2.tcl" to
ticket [3525907fff]
added by
teopetuk
2012-05-12 00:29:03.
#! /usr/bin/tclsh8.6
proc accept {chan addr port} {
fconfigure $chan -buffering none
zlib push compress $chan
puts $chan qwertyuiop
chan configure $chan -flush sync
after 5000 [list print $chan asdfghjkl]
}
proc print {chan msg} {
puts $chan $msg
close $chan
}
proc report {chan stream} {
set int [expr {[clock seconds] - $::start}]
set msg [read $chan]
if {$msg ne ""} {
puts -nonewline [$stream add $msg]
}
flush stdout
if {[eof $chan]} {
close $chan
exit 0
}
}
socket -server accept 43210
set start [clock seconds]
set chan [socket localhost 43210]
fconfigure $chan -blocking 0 -buffering none
set stream [zlib stream decompress]
fileevent $chan readable [list report $chan $stream]
vwait forever