1 # Example of a ssl encrypted, tcp 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] ssl -server certificate.pem key.pem]
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} {
24 set buf [string trim $buf]
25 puts -nonewline "read '$buf'"
28 set result "$buf = [expr $buf]"
30 set result "Error: $buf => $msg"
33 puts ", sending '$result'"
35 # Send the result back to where it came from