tcp-echo-server-naive.rkt

This commit is contained in:
Tony Garnock-Jones 2021-06-19 11:38:44 +02:00
parent 6fe031e678
commit 9fe2f923bc
1 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,22 @@
#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))])
(standard-actor-system (ds)
(at ds
(stop-on (asserted (StreamListenerError (TcpLocal host port) $message)))
(during/spawn (StreamConnection $source $sink (TcpLocal host port))
(at source (assert (Source-sink sink)))))))