1 # Example of a udp server which sends a response
3 # Listen on port 20000. No host specified means 0.0.0.0
5 set s [socket unix.dgram.server unix.sock]
7 puts "Listening on dgram socket [$s sockname]"
13 # Get the request (max 80 chars) - need the source address
14 set buf [$s recvfrom 80 addr]
16 puts -nonewline "read '$buf' from client $addr"
19 set result "$buf = [expr $buf]"
21 set result "Error: $buf => $msg"
24 puts ", sending '$result' to client $addr"
26 # Send the result back to where it came from
27 $s sendto $result $addr
30 # Handle signals so the socket is removed on exit
31 signal handle SIGINT SIGTERM