Better printing and exiting

This commit is contained in:
Tony Garnock-Jones 2014-06-21 11:54:42 -04:00
parent cee6f9158b
commit c4b14b3331
1 changed files with 13 additions and 9 deletions

View File

@ -41,19 +41,23 @@
(define local-handle (tcp-handle 'httpclient)) (define local-handle (tcp-handle 'httpclient))
(define remote-handle (tcp-address "129.10.115.92" 80)) (define remote-handle (tcp-address "129.10.115.92" 80))
(spawn (lambda (e s) (spawn (lambda (e seen-peer?)
(log-info "CLIENT: ~v" e)
(match e (match e
[(routing-update g) [(routing-update g)
#:when (not (gestalt-empty? g)) (define peer-present? (not (gestalt-empty? g)))
(transition s (send (tcp-channel (transition (or seen-peer? peer-present?)
local-handle (if (and (not peer-present?) seen-peer?)
remote-handle (quit)
#"GET / HTTP/1.0\r\nHost: stockholm.ccs.neu.edu\r\n\r\n")))] (send (tcp-channel
[(message m _ _) local-handle
remote-handle
#"GET / HTTP/1.0\r\nHost: stockholm.ccs.neu.edu\r\n\r\n"))))]
[(message (tcp-channel _ _ bs) _ _)
(printf "----------------------------------------\n~a\n" bs)
(printf "----------------------------------------\n")
#f] #f]
[_ #f])) [_ #f]))
(void) #f
(gestalt-union (pub (tcp-channel local-handle remote-handle ?)) (gestalt-union (pub (tcp-channel local-handle remote-handle ?))
(sub (tcp-channel remote-handle local-handle ?)) (sub (tcp-channel remote-handle local-handle ?))
(sub (tcp-channel remote-handle local-handle ?) #:level 1)))) (sub (tcp-channel remote-handle local-handle ?) #:level 1))))