#
# A little echo server
#
proc accept {socket address port} {
puts "Accepted connection $socket from $address\:$port"
# Copy input from the socket directly back to the socket
fcopy $socket $socket -command [list finish $socket]
}
proc finish {socket args} {
puts "Closed $socket"
catch { close $socket }
}
socket -server accept 8080
# Start the event loop by waiting on a non-existant variable 'forever'
vwait forever