chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] socket egg: socket-receive blocks?


From: Kristian Lein-Mathisen
Subject: [Chicken-users] socket egg: socket-receive blocks?
Date: Fri, 14 Jun 2013 18:01:24 +0200


Hi Chickeners!

I have come across a problem with multiple srfi-18 threads when tryping to listen to UDP sockets:

(use socket)
(set! *socket* (socket af/inet sock/dgram ))
(set! (so-reuse-address? *socket*) #t)
(socket-bind *socket* (inet-address "0.0.0.0" 5055))
;; (socket-receive ..) here blocks the prints below
;; after 1 s (about 10 hello's)
(thread-start! (lambda ()
                 (thread-sleep! 1)
                 (print "receiving ...")
                 (print (socket-receive *socket* 1024))
                 (print "done")))

(let loop ()
 (print "hello from main-thread!")
 (thread-sleep! .1)
 (loop))

;; the hello's from the main thread continue after sending a udp packet:
;; $ echo test `date` | socat - UDP-DATAGRAM:127.0.0.1:5055,broadcast


The documentation for socket clearly states that socket-receive should not block:
This call will block until data is available, but other threads can proceed.

What is wrong with my socket fd?

K.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]