2016-07-10 16:33:16 +00:00
|
|
|
#lang syndicate/actor
|
2016-01-13 16:26:01 +00:00
|
|
|
|
2016-04-01 23:53:46 +00:00
|
|
|
(require syndicate/drivers/tcp)
|
2016-01-13 16:26:01 +00:00
|
|
|
|
2016-02-05 23:03:40 +00:00
|
|
|
(spawn-tcp-driver)
|
2016-01-13 16:26:01 +00:00
|
|
|
|
2016-02-05 23:03:40 +00:00
|
|
|
(define server-id (tcp-listener 5999))
|
2016-07-09 20:18:30 +00:00
|
|
|
(actor
|
|
|
|
(forever (assert (advertise (observe (tcp-channel _ server-id _))))
|
|
|
|
(during/actor (advertise (tcp-channel $c server-id _))
|
|
|
|
(on-start (printf "Accepted connection from ~v\n" c))
|
|
|
|
(assert (advertise (tcp-channel server-id c _)))
|
|
|
|
(on (message (tcp-channel c server-id $bs))
|
|
|
|
(send! (tcp-channel server-id c bs)))
|
|
|
|
(on-stop (printf "Closed connection ~v\n" c)))))
|