unable to receive on a UDP broadcast socket

I have found that I am unable to receive on a UDP socket that was used to send a broadcast message. With the use of wireshark I know that on my MAC running MAC OS 10.13.2, the correct protocol query (netbios name query) is sent, and I know that a valid response is sent back to the sending socket address. I also use the nettop application to watch the socket state and I can see that the 62 byte response is added to the sockets inbuffer each time a response is seen. However the attempted receive on the socket by the program that created it simply times out and sees no data.


I found behavior when I noted that Finder GO-TO-SERVER could not resolve a name on my local network. (It used to work, but I think failed once Sierra was installed). I investigated further with the use of mdutil and find that the lookup request consitently fails. Finally I found a simple python program that creates NetBIOS name query, broadcasts it on a UDP socket and then attempts to read the response. It consistently fails to see any data at all on the socket. I have run the exact same program on a virtual box fedora system running on the same MAC on the same network looking for the same PC and it works relyably.


So my conclusion is that there is some setting some place in the MAC os network that is telling it to not allow a program to seen any data in the inbuffer of a UDP socket, if that socket was used to send to a broadcast socket. Since nettop sees the data in the inbuffer, sure looks like, the lower level network driver is not dropping the packet. But the upper network code is simply not telling the client program that this is data available when it asks for it.


I've been beating my head on this for a good number of months now and sure would appreciate any pointers that anyone has.

Ok so I think I have an answer. But first a correction. I mentioned the use of mdutil, when I should have said smbutil.


I had set the firewall to block incoming connections. Seems prudent in general. Well it appears that the MAC assumes that a response on a UDP socket that was created by an application running on the MAC is an incoming connection. In my view that is a continuing communication on a local socket. But once I changed the firewall setting to not block all incoming connections both smbutil and the python program I was using to investigate the issue started to work!


Seems strange to me, so now I would hope some once could explain this behavior to me.

unable to receive on a UDP broadcast socket
 
 
Q