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))) ; ;