[Openmcl-devel] Blocking problem with UDP broadcast on a LAN with macOSX

barthes barthes at utc.fr
Mon Feb 1 01:14:18 PST 2021


I have several machines on a LAN (some of them unknown) and need to send 
broadcast messages to all of them. I encounter a problem with UDP broadcast. I have been 
running a number of tests and always end up with the same problem, although UDP 
point-to-point works well. 

The following example is one of the simplest tests I ran: A and B are 2 machines on the 

A: CCL 1.11.6 DarwinX8664 on macOS Sierra 10.12.6, sending UDP messages

A.1. P2P

(defparameter *s* (make-socket :type :datagram 
                               :remote-host ""
                               :remote-port 35005))

(let* ((text (format nil "UDP Test Message"))
       (buf (encode-string-to-octets text))
  (send-to *s* buf (length buf) :remote-host "")

A.2. Broadcast

(defparameter *ss* 
  (make-socket :type :datagram :broadcast t
               :remote-host "" :remote-port 35005))

(let* ((text (format nil "UDP Test Broadcast Message"))
       (buf (encode-string-to-octets text))
  (send-to *ss* buf (length buf))

B: CCL 1.11.8 DarwinX8664 on macOS Mojave 10.14.6 receiving

(defparameter *s* (make-socket :type :datagram {:broadcast t} ; tried with and without
                               :local-host "" :local-port 35005))
(defun s-receive ()
 (let (buf)
     (print "Ready")
     (setq buf (receive-from *s* 1000 :extract t))
     (print buf))

(setq proc (process-run-function "UDP test" #'s-receive))

Test A1 (P2P) works like a breeze, B prints the content of the buffer.

Test A2 (Broadcast): the messages is sent by A and appears on the LAN (as checked with 
tcpdump from the terminal) but does not reach the B Lisp environment. Nothing is printed 
and B keeps waiting.

tcpdump on B shows that the message is received...
> sudo tcpdump udp port 35005
10:02:00.244874 IP notebook.home.54899 > UDP, length 26

None of the machine has a firewall up. Both machines were rebooted before each test.

I am probably missing something trivial (in that case sorry for wasting your time), 
but I ran out of ideas. Could anyone tell me what I am doing wrong?

Thank you.

More information about the Openmcl-devel mailing list