Last active
April 17, 2022 10:18
-
-
Save AiziChen/acb42dcb0d04c9dfd957210350a9e8a7 to your computer and use it in GitHub Desktop.
UDP server/client and synchronize event
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket/base | |
(require racket/udp) | |
(define udp (udp-open-socket)) | |
(udp-send-to udp "ip-address" 12345 #"hello") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket/base | |
(require racket/udp) | |
(define udp (udp-open-socket)) | |
(udp-bind! udp "0.0.0.0" 12345) | |
(define bs (make-bytes 1024)) | |
(let loop () | |
(sync (handle-evt | |
(udp-receive!-evt udp bs) | |
(lambda (rs) | |
(displayln (subbytes bs 0 (car rs)))))) | |
(loop)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment