Add a UDP example
This commit is contained in:
parent
9536b0affa
commit
e1cf9a35b5
1 changed files with 18 additions and 0 deletions
18
examples/udp_server.scm
Normal file
18
examples/udp_server.scm
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
(load "../bindings/libc.scm")
|
||||||
|
|
||||||
|
(define (check-err ret msg)
|
||||||
|
(cond
|
||||||
|
((< ret 0)
|
||||||
|
(perror msg)
|
||||||
|
(raise msg))
|
||||||
|
(#t ret)))
|
||||||
|
|
||||||
|
(define (udp-sock fx)
|
||||||
|
(fx
|
||||||
|
(check-err
|
||||||
|
(socket 'AF_INET 'SOCK_DGRAM 'IPPROTO_NONE)
|
||||||
|
"Unable to init UDP socket")))
|
||||||
|
|
||||||
|
(udp-sock
|
||||||
|
(lambda (s)
|
||||||
|
(printf "~a~%" s)))
|
Loading…
Reference in a new issue