From 413840382b6f030b221c89eaaa3df6b77ff51eca Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Thu, 9 Feb 2017 19:24:02 -0500 Subject: [PATCH] Better crash-handling for simplified TCP protocol sketch --- .../syndicate/examples/actor/chat-simplified-internals2.rkt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/racket/syndicate/examples/actor/chat-simplified-internals2.rkt b/racket/syndicate/examples/actor/chat-simplified-internals2.rkt index 4d6ae74..8111a06 100644 --- a/racket/syndicate/examples/actor/chat-simplified-internals2.rkt +++ b/racket/syndicate/examples/actor/chat-simplified-internals2.rkt @@ -9,6 +9,7 @@ ;; Sketch of a translation from the existing TCP protocol into a simpler one (struct tcp-connection (id spec) #:prefab) +(struct tcp-accepted (id) #:prefab) (struct tcp-out (id text) #:prefab) (struct tcp-in (id text) #:prefab) @@ -18,7 +19,7 @@ (on (asserted (advertise (tcp-channel $them us _))) (define id (seal (list them us))) (actor (stop-when (retracted (advertise (tcp-channel them us _)))) - (stop-when (retracted (observe (tcp-connection id us)))) + (stop-when (retracted (tcp-accepted id))) (assert (tcp-connection id us)) (on (message (tcp-channel them us $bs)) (send! (tcp-in id (string-trim (bytes->string/utf-8 bs))))) @@ -33,6 +34,7 @@ (actor #:name 'chat-server (during/actor (tcp-connection $id (tcp-listener 5999)) + (assert (tcp-accepted id)) (define me (gensym 'user)) ;; a random user name (assert (present me)) (during (present $user)