schemelib/examples/udp_server.scm

19 lines
584 B
Scheme
Raw Permalink Normal View History

2020-07-14 18:58:10 +00:00
(source-directories '("." ".."))
(include "io/udpsock.scm")
(include "bindings/utils.scm")
2020-07-09 10:51:53 +00:00
2020-07-09 10:15:00 +00:00
(udpsock-create
2020-07-09 10:51:53 +00:00
(lambda (sock)
(udpsock-reuseaddr sock)
2020-07-09 15:51:13 +00:00
(udpsock-bind sock "127.0.0.8" 1337)
2020-07-10 08:32:46 +00:00
(udpsock-io
2020-07-09 13:59:25 +00:00
sock
2020-07-10 08:32:46 +00:00
(lambda (host port buf nread send)
(let* ([charbuf (make-ftype-pointer char buf)]
[udpmsg (char*->string charbuf nread)])
(printf
"host: ~a, port: ~a, nread: ~a, buf: ~a~%"
host port nread udpmsg)
(send host port (ftype-pointer-address (string->char* udpmsg charbuf nread)) nread)
)))))