I guess I was tunnel visioned and lost clarity (and also, common sense). While searching for reasons why the code (from Graham King’s blog) had worked on Linux and not on macOS, a stack overflow answer [1] from 2015, from a person who had also been on the same journey, directed me to that page [2] — that talked about raw socket peculiarities in FreeBSD. So I dived straight into FreeBSD docs.
[1]- https://stackoverflow.com/a/32599757/3728336
[2] - https://cseweb.ucsd.edu/~braghava/notes/freebsd-sockets.txt