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 # Make this server forking so we can accept multiple
10 # simultaneous connections
14 # Get the request (max 80 chars) - need the source address
15 while {[$sock gets buf] >= 0} {
16 set buf [string trim $buf]
17 puts -nonewline "read '$buf'"
20 set result "$buf = [expr $buf]"
22 set result "Error: $buf => $msg"
25 puts ", sending '$result'"
27 # Send the result back to where it came from