Plain-racket echo variation.

This commit is contained in:
Tony Garnock-Jones 2013-04-26 17:43:25 -04:00
parent 8df8ecd215
commit 7d2e832a97
1 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,18 @@
#lang racket/base
;; Plain Racket version, using (require) instead of #lang marketplace.
(require marketplace/sugar-untyped)
(require marketplace/drivers/tcp-bare)
(define (echoer from to)
(transition/no-state
(endpoint
#:subscriber (tcp-channel from to ?)
#:on-absence (quit)
[(tcp-channel _ _ data)
(send-message (tcp-channel to from data))])))
(ground-vm tcp
(endpoint #:subscriber (tcp-channel ? (tcp-listener 5999) ?)
#:conversation (tcp-channel from to _)
#:on-presence (spawn #:child (echoer from to))))