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 dgram.server 20000]
8 # Get the request (max 80 chars) - need the source address
9 set buf [$s recvfrom 80 addr]
11 puts -nonewline "read '$buf' from $addr"
14 set result "$buf = [expr $buf]"
16 set result "Error: $buf => $msg"
19 puts ", sending '$result' to $addr"
21 # Send the result back to where it came from
22 $s sendto $result $addr