Posted to tcl by aspect at Tue May 10 08:25:45 GMT 2011view pretty
#!/usr/bin/tclsh # proc readfrom {chan} { set buf [read $chan] if {$buf != ""} { puts "Read {$buf}" } if {[eof $chan]} { puts "EOF!" close $chan } } proc accept {chan addr port} { fconfigure $chan -blocking 0 -buffering none fileevent $chan readable [list readfrom $chan] } set sock [socket -server accept 1234] vwait forever