#!/usr/bin/tclsh # # need to bind to port 80, so needs root privilege # # Usage: sudo tclsh $0 set serversock [socket -server httpAccept 80] set quit 0 proc httpAccept { s caddr cport } \ { puts "ACCEPT from ${caddr}:${cport} [clock format [clock seconds] -format {%Y-%m-%dT%T}]" fconfigure $s -translation auto while {[gets $s line] > 0} { puts stdout $line } puts stdout "-- " puts $s "HTTP/1.0 200 OK" puts $s "X-Organization: Nintendo" puts $s "" close $s } puts "-- waiting for connection" vwait quit