From: Christopher Allan Webber Date: Sun, 11 Dec 2016 00:22:12 +0000 (-0600) Subject: Correcty disconnect from clients which provide the eof-object X-Git-Tag: fosdem-2017~132 X-Git-Url: https://jxself.org/git/?p=mudsync.git;a=commitdiff_plain;h=06874e6aff593e00d587ad756fe781cb980e143b;hp=095dde9158621c8bb3d690feaa0d525a76342eb9 Correcty disconnect from clients which provide the eof-object --- diff --git a/mudsync/networking.scm b/mudsync/networking.scm index 5259975..230008f 100644 --- a/mudsync/networking.scm +++ b/mudsync/networking.scm @@ -136,18 +136,13 @@ (define (nm-client-receive-loop nm client client-id) "Make a method to receive client data" (define (loop) - (define line (string-trim-right (read-line client) #\return)) - (nm-handle-line nm client client-id line) - (cond - ;; The port's been closed for some reason, so stop looping - ((port-closed? client) - (nm-handle-port-closed nm client client-id)) - ;; We've reached the EOF object, which means we should close - ;; the port ourselves and stop looping - ((eof-object? (peek-char client)) - (nm-handle-port-eof nm client client-id)) - ;; Otherwise, let's read till the next line! - (else (loop)))) + (define line (read-line client)) + (if (eof-object? line) + (nm-handle-port-eof nm client client-id) + (begin + (nm-handle-line nm client client-id + (string-trim-right line #\return)) + (loop)))) (loop)) (define (nm-handle-port-closed nm client client-id)