Posted to tcl by kostix at Thu May 07 00:13:03 GMT 2009view raw
- proc Connected {sock host port} {
- puts "Connected: $host:$port"
- chan event $sock readable [list Read $sock]
- chan config $sock -buffering none -blocking no
- }
- proc Read sock {
- if {[gets $sock line] < 0} {
- chan close $sock
- set ::forever now
- } else {
- puts $sock "ECHO: $line"
- }
- }
- set sock [socket -server Connected 6666]
- vwait forever
- ----
- test client:
- $ (while true; do echo 'line'; done) | netcat localhost 6666 | while read LINE; do echo "`date`: $LINE"; done