Version 1 of 8-Line Server

Updated 2009-05-28 18:54:52 by jdp

jdp - An 8 line server. Serves text files out of the current directory.

proc s {c a p} {
        set o [lindex [split [gets $c] " "] 1]
        puts $c [read [set f [open ".$o"]]]
        close $f
        close $c
set s [socket -server s 3210]
vwait forever

jdp - After discussion in the chatroom, either (but not both) of the following lines can replace the body of proc s:

[puts $c [read [set f [open .[string map {. ""} [lindex [split [gets $c] " "] 1]]]]][close $f]][close $c]
puts $c [read [set f [open .[string map {. ""} [lindex [split [gets $c] " "] 1]]]]][close $f];[close $c]

enter categories here