1 # Example of a unix domain stream server which sends a response
4 set s [socket unix.server unix.tmp]
6 puts "Listening on [$s sockname]"
13 # Make this server forking so we can accept multiple
14 # simultaneous connections
16 # We don't want the unix domain path to be deleted here
21 # Get the requests, one line at a time an evaluate
22 while {[$sock gets buf] >= 0} {
23 set buf [string trim $buf]
24 if {$buf in {? help}} {
25 set result "Enter any Tcl command to run in the server"
28 set result [eval $buf]
29 set result [string map [list \\ \\\\ \n \\n \r \\r] $result]
31 set result "Error: $buf => $msg"
35 # Send the result back to where it came from
43 # Handle signals so the socket is removed on exit
44 signal handle SIGINT SIGTERM