syndicate-rkt/syndicate-examples/echo.rkt

17 lines
671 B
Racket
Raw Normal View History

2021-06-04 13:56:03 +00:00
;;; SPDX-License-Identifier: LGPL-3.0-or-later
;;; SPDX-FileCopyrightText: Copyright © 2010-2021 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
2020-04-27 18:27:48 +00:00
#lang syndicate
(require/activate syndicate/drivers/tcp)
(spawn (during/spawn (tcp-connection $id (tcp-listener 5999))
(on-start (printf "Accepted connection ~v\n" id))
(on-stop (printf "Closed connection ~v\n" id))
(assert (tcp-accepted id))
(on-start (issue-credit! (tcp-listener 5999))
(issue-credit! tcp-in id))
(on (message (tcp-in-line id $bs))
2020-04-27 19:21:40 +00:00
(issue-credit! tcp-in id)
2020-04-27 18:27:48 +00:00
(send! (tcp-out id (bytes-append bs (bytes 13 10)))))))