Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: ListenMulticastUDP should not disable loopback or should specify this in docs #41752

Open
stalker-loki opened this issue Oct 2, 2020 · 2 comments

Comments

@stalker-loki
Copy link

@stalker-loki stalker-loki commented Oct 2, 2020

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.

@ianlancetaylor ianlancetaylor changed the title ListenMulticastUDP should not disable loopback or should specify this in docs net: ListenMulticastUDP should not disable loopback or should specify this in docs Oct 2, 2020
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Oct 2, 2020

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.

@networkimprov
Copy link

@networkimprov networkimprov commented Oct 3, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.