Posted to tcl by schelte at Thu Aug 28 09:30:22 GMT 2014view raw
- socket -server server $port
- proc server {fd host port} {
- fconfigure $fd -blocking 0 -buffering line
- fileevent $fd readable [list receive $fd]
- }
- proc receive {fd} {
- if {[eof $fd]} {
- close $fd
- } elseif {[gets $fd line] != -1} {
- switch -- $line {
- a {puts $fd b}
- c {puts $fd d}
- }
- }
- }