diff --git a/examples/udp_server.scm b/examples/udp_server.scm new file mode 100644 index 0000000..c7a63cd --- /dev/null +++ b/examples/udp_server.scm @@ -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)))