Make this a real running program
This commit is contained in:
parent
4cab8d3226
commit
c3f27a9e8d
|
@ -2,19 +2,19 @@
|
|||
|
||||
(define (listener port)
|
||||
(transition 'no-state
|
||||
(role/act (tcp-listener port)
|
||||
#:topic t
|
||||
#:on-presence (spawn (connection-handler t))))))
|
||||
(role/anon (tcp-listener port)
|
||||
#:topic t
|
||||
#:on-presence (spawn (connection-handler t)))))
|
||||
|
||||
(define (connection-handler topic)
|
||||
(define-values (cin cout in-topic out-topic) (tcp-accept topic))
|
||||
(define (connection-handler t)
|
||||
(define-values (cin cout in-topic out-topic) (tcp-accept t))
|
||||
(transition 'no-state
|
||||
(cin (tcp-credit 1) #:mode 'feedback)
|
||||
(role/act in-topic
|
||||
(cin (tcp-credit 1))
|
||||
(role/anon in-topic
|
||||
[(tcp-channel _ _ (or (== #"\4") (? eof-object?)))
|
||||
(kill)]
|
||||
[(tcp-channel _ _ (? bytes? bytev))
|
||||
(list (cin (tcp-credit 1) #:mode 'feedback)
|
||||
[(tcp-channel _ _ bytev)
|
||||
(list (cin (tcp-credit 1))
|
||||
(cout bytev))])))
|
||||
|
||||
(define (main port)
|
||||
|
@ -25,27 +25,6 @@
|
|||
|
||||
(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)
|
||||
(require "os2.rkt")
|
||||
(require "os2-tcp.rkt")
|
||||
(require "os2-tcp-helper.rkt")
|
||||
(require "../os2.rkt")
|
||||
(require "../fake-tcp.rkt")
|
||||
|
|
Loading…
Reference in New Issue