#lang syndicate ;;; SPDX-License-Identifier: LGPL-3.0-or-later ;;; SPDX-FileCopyrightText: Copyright © 2021 Tony Garnock-Jones (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)) (standard-actor-system (ds) (at ds (stop-on (asserted (TcpListenError (TcpLocal host port) $message))) (during/spawn (StreamConnection $source $sink (TcpLocal host port)) (handle-connection source sink #:initial-mode (Mode-lines (LineMode-lf)) #:on-data (lambda (data mode) (send! ds (Line data)))) (at ds (on (message (Line $data)) (send-line sink data)))))))