Refactor
This commit is contained in:
parent
33653804dc
commit
772a87dc24
1 changed files with 17 additions and 14 deletions
|
@ -7,24 +7,27 @@
|
|||
(raise msg))
|
||||
(#t ret)))
|
||||
|
||||
(define (udp-sock fx)
|
||||
(define (udpsock-create fx)
|
||||
(fx
|
||||
(check-err
|
||||
(socket 'AF_INET 'SOCK_DGRAM 'IPPROTO_IP)
|
||||
"Unable to init UDP socket")))
|
||||
|
||||
(udp-sock
|
||||
(lambda (s)
|
||||
(define (udpsock-reuseaddr sock)
|
||||
(alloc
|
||||
(ftype-sizeof int)
|
||||
(lambda (activation)
|
||||
(foreign-set! 'int activation 0 1)
|
||||
(check-err
|
||||
(setsockopt
|
||||
s
|
||||
sock
|
||||
'SOL_SOCKET
|
||||
'SO_REUSEADDR
|
||||
activation
|
||||
(ftype-sizeof int))
|
||||
"Unable to set REUSE ADDRESS")))
|
||||
"Unable to set REUSE ADDRESS"))))
|
||||
|
||||
(udpsock-create
|
||||
(lambda (s)
|
||||
(udpsock-reuseaddr s)
|
||||
(printf "~a~%" s)))
|
||||
|
|
Loading…
Reference in a new issue