From 8dbc1994bc91ffe331b3c83a8d22acdb3fef7766 Mon Sep 17 00:00:00 2001 From: Matthias Felleisen Date: Sun, 27 Mar 2011 13:54:22 -0400 Subject: [PATCH] small change to registration format --- collects/2htdp/private/check-aux.rkt | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/collects/2htdp/private/check-aux.rkt b/collects/2htdp/private/check-aux.rkt index 42d0fba967..35a0408e35 100644 --- a/collects/2htdp/private/check-aux.rkt +++ b/collects/2htdp/private/check-aux.rkt @@ -124,23 +124,22 @@ (read-line in) ;; read the newline x)))) -(define REGISTER '***register***) -(define OKAY '***okay***) - ;; InPort OutPort (X -> Y) -> (U Y Void) ;; process a registration from a potential client, invoke k if it is okay (define (tcp-process-registration in out k) (define next (tcp-receive in)) - (when (and (pair? next) (eq? REGISTER (car next))) - (tcp-send out OKAY) - (k (cdr next)))) + (match next + [`(REGISTER ((name ,name))) + (tcp-send out '(OKAY)) + (k name)])) - ;; InPort OutPort (U #f String) -> Void ;; register with the server (define (tcp-register in out name) - (tcp-send out `(,REGISTER ,(if name name (symbol->string (gensym 'world))))) - (unless (eq? (tcp-receive in) OKAY) (raise tcp-eof))) + (tcp-send out `(REGISTER ((name ,(if name name (symbol->string (gensym 'world))))))) + (define ackn (tcp-receive in)) + (unless (equal? ackn '(OKAY)) + (raise tcp-eof))) ; ;