
proc conn {s args} {
    puts "<$s> $args"
    fconfigure $s -buffering line  
    after 3000 [list hello $s]
}
proc hello {s} {
    puts hello
    puts $s hello-world
    after 3000 [list empty $s]
}
proc empty {s} {
    puts empty
    puts $s {}
    after 3000 [list more $s]
}
proc more {s} {
    puts more
    puts $s more-lines
    after 3000 [list another $s]
}
proc another {s} {
    puts another
    puts $s another-line
    after 3000 exit_
}
proc exit_ {} {
    puts exit
    exit
}

socket -server conn 7777
vwait forever
