Solved by someone from the FreeBSD forums. To quote them,

<--

What's going wrong here is that the listener is listening on a udp6 socket, but the talker sends on a udp4 socket.

If you change this line in listener.c:

Code:
hints.ai_family = AF_UNSPEC; // set to AF_INET to force IPv4
to use AF_INET instead of AF_UNSPEC, then everything works fine.

-->

I still don't see why this works in Linux but not FreeBSD. Anyway, thanks for all replies.