Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
net: ListenMulticastUDP should not disable loopback or should specify this in docs #41752
This function internally sets the loopback flag to disabled and thus it is impossible to write tests for a single machine. The flag does not appear to be disabled on any OS except windows though I think in the code it supposedly disables this on other platforms.
The comment glosses completely over what a 'simple multicast application' means and surely the simplest multicast application is a pair of goroutines in a single runtime pushing data across this for tests. In this respect you can say that the contract is not specified correctly ("simple application" does not imply no loopback) and it took quite some searching to actually find the way around this. This is some code that enables loopback for multicast UDP: https://github.com/p9c/pod/blob/master/pkg/comm/multicast/channel.go
Either the comment should be changed to point out that loopback does not function on Windows, or the flag should set to enabled by default as this is the behavior implied in the contract from the documentation, or this functionality should be exposed.
I have the solution for my specific needs, so that's all very well and good but I would like to hear the arguments against flipping it to enabled loopback and justifications for this setting being unspecified and buried two levels deep in the code.
I don't claim to understand all the nuances here. But clearing the loopback flag was introduced in https://golang.org/cl/5562048 before the Go 1 release, so I think we are unlikely to change that now.
Improving the documentation would of course be fine.