Minor corrections and elaborations
This commit is contained in:
parent
9791100322
commit
5797a25789
|
@ -7,7 +7,7 @@
|
|||
(thread (connection-handler cin cout))
|
||||
(loop)))
|
||||
|
||||
(define (connection-handler cin cout)
|
||||
(define ((connection-handler cin cout))
|
||||
(let connection-loop ()
|
||||
(define v (read-byte cin))
|
||||
(unless (or (eof-object? v) (equal? v #"\4"))
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
(role/act in-topic
|
||||
[(tcp-channel _ _ (or (== #"\4") (? eof-object?)))
|
||||
(kill)]
|
||||
[(tcp-channel _ _ (? bytes? line))
|
||||
[(tcp-channel _ _ (? bytes? bytev))
|
||||
(list (cin (tcp-credit 1) #:mode 'feedback)
|
||||
(cout line))])))
|
||||
(cout bytev))])))
|
||||
|
||||
(define (main port)
|
||||
(ground-vm
|
||||
|
@ -25,6 +25,24 @@
|
|||
|
||||
(main 5999)
|
||||
|
||||
(define (tcp-accept topic)
|
||||
(match-define (topic (tcp-channel remote-addr local-addr _)) topic)
|
||||
(values (match-lambda
|
||||
[(val #:mode 'feedback)
|
||||
(send-feedback (tcp-channel remote-addr local-addr val))])
|
||||
(match-lambda
|
||||
[(val)
|
||||
(send-message (tcp-channel local-addr remote-addr val))])
|
||||
(topic-subscriber (tcp-channel remote-addr local-addr (wild)))
|
||||
(topic-publisher (tcp-channel local-addr remote-addr (wild)))))
|
||||
|
||||
|
||||
(define (tcp-listener port)
|
||||
(topic-subscriber (tcp-channel (wild)
|
||||
(tcp-local-endpoint port)
|
||||
(wild))
|
||||
#:monitor? #t))
|
||||
|
||||
(require racket/string)
|
||||
(require racket/set)
|
||||
(require racket/match)
|
||||
|
|
Loading…
Reference in New Issue