net: ListenMulticastUDP should not disable loopback or should specify this in docs #41752
Labels
Documentation
FrozenDueToAge
help wanted
NeedsFix
The path to resolution is known, but the work has not been done.
Milestone
https://golang.org/pkg/net/#ListenMulticastUDP
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.
The text was updated successfully, but these errors were encountered: