syndicate-rkt/syndicate-examples/udp-echo.rkt

14 lines
473 B
Racket

;;; SPDX-License-Identifier: LGPL-3.0-or-later
;;; SPDX-FileCopyrightText: Copyright © 2010-2021 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
#lang syndicate
(require/activate syndicate/drivers/udp)
(spawn (define s (udp-listener 5999))
(during s
(on (message (udp-packet $c s $body))
(printf "~a: ~v\n" c body)
(define reply (string->bytes/utf-8 (format "You said: ~a" body)))
(send! (udp-packet s c reply)))))