Artifact
20086ef2dc27086db4d04e46135a0b72375a9610:
Attachment "zchanstack.tcl" to
ticket [2536400fff]
added by
flatworm
2009-01-26 07:35:45.
package require Tcl 8.6
if {[lindex $argv 0] eq "client"} {
set sock [socket localhost 6666]
zlib push compress $sock
chan config $sock -encoding binary -buffering none -flush sync
while {[gets stdin line] >= 0} {
puts $sock $line
}
chan close $sock
} elseif {[lindex $argv 0] eq "server"} {
proc Read {sock} {
puts -nonewline [read $sock]
if {[chan eof $sock]} {
chan close $sock
}
}
proc Accept {sock addr port} {
close $sock
}
set sock [socket -server Accept 6666]
vwait ::forever
}