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

11 lines
349 B
Racket

#lang imperative-syndicate
(require/activate imperative-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)))))