-
Notifications
You must be signed in to change notification settings - Fork 436
Open
Description
If I load the code for serve-persistent
as written, my telnet session closes immediately after it receives the response. It appears that the problem is cased by having the second with-open
inside the while
loop. I changed the code a bit and it appears to work as expected:
(defn serve-persistent [port handler]
(let [running (atom true)]
(future
(with-open [server-sock (ServerSocket. port)
sock (.accept server-sock)]
(while @running
(let [msg-in (receive sock)
msg-out (handler msg-in)]
(send sock msg-out)))))
running))
Also note that send
conflicts with clojure.core/send
, so in my code, I've renamed it to send-msg
. I didn't change it here to match what is above.
Thanks,
Kevin
Metadata
Metadata
Assignees
Labels
No labels