- Notifications
You must be signed in to change notification settings - Fork434
Open
Description
If I load the code forserve-persistent
as written, my telnet session closes immediately after it receives the response. It appears that the problem is cased by having the secondwith-open
inside thewhile
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 thatsend
conflicts withclojure.core/send
, so in my code, I've renamed it tosend-msg
. I didn't change it here to match what is above.
Thanks,
Kevin
Metadata
Metadata
Assignees
Labels
No labels