Posted to tcl by apn at Sun Jul 03 03:00:54 GMT 2022view pretty
Run server.tcl in one command window Run client.tcl in another. Client output is d:\src\tcltk\console\tests>tclsh client.tcl <abc> <defghi> <> <jkl> What's the extra blank line <> doing there ? Files are below: server.tcl ------------ proc accept {so args} { fconfigure $so -translation binary puts -nonewline $so "abc\r" puts -nonewline $so "\ndef" flush $so #Now force separate packets puts -nonewline $so "ghi\r" flush $so after 1000 puts -nonewline $so "\njkl" flush $so close $so set ::done 1 } set so [socket -server accept 10000] vwait done ------ client.tcl ------ set chan [socket 127.0.0.1 10000] fileevent $chan readable { if {[gets $chan line] >= 0} { puts <$line> } elseif {[eof $chan]} { set done 1 } } fconfigure $chan -blocking 0 -buffering line vwait done