Hello,
I am working on a (linux) app that needs to join Source-Specific Multicast channels, and am looking for some better options on how to accomplish this with golang.
I’ve made some initial progress by adapting much of the logic behind net.ListenMulicastUDP() into my own package, with some tweaks to:
A) Allow the Source address to be passed through in the setsockopt call that triggers the Multicast join (syscall.IP_ADD_SOURCE_MEMBERSHIP).
B) Bypass the provisions for shared-access and nonblocking-IO provided by net.UDPConn and instead work directly on the socket’s file descriptor. I only need to read a single multicast channel from a single goroutine, so I don’t miss the shared-access logic. I would have liked to use the nonblocking IO provided by netFd, but there are dependencies on runtime assembly (see: fd_poll_runtime.go) that I couldn't figure out how to tease out of the "net" package.
In isolation, this approach works, and I’m able to use syscall.Recvfrom() to pull the datagrams from the multicast channel. However, when I introduced other goroutines in my app that are performing unrelated blocking IO (to the filesystem), I start running into problems that seem to manifest as missing packets from multicast stream. I’m still trying to debug/understand this.
Before I get too far off on this tangent, I thought it would be a good time to check in with this group to see if there are other/better ideas to get Source-Specific Multicast working with go.
Thanks in advance for any pointers, feedback, or ideas you think may be helpful.
Regards,
Coby Young