2021-06-11 13:29:12 +00:00
|
|
|
#lang syndicate
|
|
|
|
;;; SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
;;; SPDX-FileCopyrightText: Copyright © 2021 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
|
|
|
|
|
|
|
|
(module+ main
|
|
|
|
(require racket/cmdline)
|
|
|
|
(require syndicate/drivers/tcp)
|
|
|
|
|
|
|
|
(define host "0.0.0.0")
|
|
|
|
(define port 5999)
|
|
|
|
|
|
|
|
(command-line #:once-each
|
|
|
|
[("--host" "-H") hostname "Set hostname to listen on"
|
|
|
|
(set! host hostname)]
|
|
|
|
[("--port" "-p") port-number "Set port number to listen on"
|
|
|
|
(set! port (string->number port-number))])
|
|
|
|
|
|
|
|
(message-struct Line (text))
|
|
|
|
|
|
|
|
(actor-system/dataspace (ds)
|
|
|
|
(spawn-tcp-driver ds)
|
|
|
|
(spawn
|
|
|
|
(at ds
|
2021-06-15 10:36:25 +00:00
|
|
|
(during/spawn (Connection $conn (TcpLocal host port))
|
2021-06-11 13:29:12 +00:00
|
|
|
(accept-connection conn
|
|
|
|
#:initial-mode (Mode-lines (LineMode-lf))
|
|
|
|
#:on-data (lambda (data mode) (send! ds (Line data))))
|
|
|
|
(at ds (when (message (Line $data)) (send-line conn data))))))))
|