Created
December 14, 2008 01:53
-
-
Save francois/35596 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn process [socket] | |
(let [ in (java.io.PushbackReader. (make-reader (. socket getInputStream))) | |
out (java.io.PrintWriter. (make-writer (. socket getOutputStream)))] | |
(loop [stack ()] | |
(let [form (read in)] | |
(println "STACK:\t" stack) | |
(println "READ:\t" form) | |
(cond | |
(number? form) (recur (conj stack form)) | |
(= 'quit form) (do | |
(. out println "Connection closed by client, closing socket") | |
(. out flush) | |
(. socket close)) | |
:else (do | |
(. out println "Syntax error: unrecognized form" form) | |
(. out flush) | |
(. socket close))))))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment