if {1} {
    set chan [socket 127.0.0.1 10000]
} else {
    set chan stdin
}
fileevent $chan readable {
    if {[gets $chan line] >= 0} {
        puts <$line>
    } elseif {[eof $chan]} {
        set done 1
    }
}
fconfigure $chan -blocking 0 -buffering line
vwait done
