1 # Example of a udp server which sends a response
3 # Listen on port 20000. No host specified means 0.0.0.0
4 set s [socket stream.server 20000]
9 set sock [$s accept addr]
10 puts "Client address: $addr"
12 # Make this server forking so we can accept multiple
13 # simultaneous connections
19 # Get the request (max 80 chars) - need the source address
20 while {[$sock gets buf] >= 0} {
21 set buf [string trim $buf]
22 puts -nonewline "read '$buf'"
25 set result "$buf = [expr $buf]"
27 set result "Error: $buf => $msg"
30 puts ", sending '$result'"
32 # Send the result back to where it came from