-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: ListenUDP doesn't work with ":port" or "0.0.0.0:port" on Windows #22811
Comments
What does Go 1.9 on Linux do? |
Tentatively flagging this as Go 1.11 for now, until more is known. |
(We can fix it earlier if warranted.) |
I updated my Go installation to Output: Same as in playground.
I downgraded my Go installation to Output: |
The error comes from |
The error happens in https://play.golang.org/p/LBPPVD9H9e on line 48
which calls Windows WSASendTo API that fails with WSAEADDRNOTAVAIL. According to https://msdn.microsoft.com/en-us/library/windows/desktop/ms741693(v=vs.85).aspx - "... WSAEADDRNOTAVAIL - The remote address is not a valid address (such as ADDR_ANY) ...". I suspect we use ADDR_ANY here.
Yes, that will fix it. But maybe we could handle code as is. Leaving for @mikioh and @bradfitz to decide what to do here. Alex |
@alexbrainman So it is fine to use EDIT: Although either the docs or the error should point to this solution if it's the proper way to do it. |
I guess that the snippet below could help to understand the circumstances:
|
I do not know the answer to your question. I am not an expert in this area, and I do not want to confuse you. I will defer to Mikio. Alex |
If you don't specify an address to listen, it will listen on all addresses. Maybe the document(https://golang.org/pkg/net/#Dial) should be better. It is
I think "the local system" is confusing. |
The meaning of an empty host is documented in three functions. https://golang.org/pkg/net/#Dial
https://golang.org/pkg/net/#Listen
https://golang.org/pkg/net/#ListenPacket
So an empty host is an unspecified address in
This sentence repeated 9 times in https://golang.org/pkg/net The problem is, a |
There's #22827 for tracking the root cause of this issue, feel free to close this issue.
For connection setup, you need to let the protocol stack inside the kernel know what your endpoint wants to receive. For data transmission, you must be sure the passing destination identifier is appropriate for the protocol stack inside the kernel. In your case, the IPv4 address 0.0.0.0/32 or IPv6 address ::/128 is valid for connection setup because the address is considered as a wildcard reception address by convention. However, as described in #22827, 0.0.0.0/32 or ::/128 is not valid for data transmission because it's invalid for IP routing. Feel free to open a new issue for documentation improvement and send a CL. |
Ok, then I'm closing this! @mikioh Sure, that makes perfect sense, just wanted to confirm. Anyway it's very weird that EDIT: I'll confirm my suspicions on this, recheck docs and create another issue if something doesn't add up. |
What version of Go are you using (
go version
)?go version go1.9.2 windows/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?What did you do?
Here's a program that works perfectly on linux (tried on
go version go1.5.1 linux/amd64
and playground):https://play.golang.org/p/LBPPVD9H9e
It starts two UDP listeners (
:11000
and:11001
), sets up a reader for each listener, tries sending a message from server1 to server2 and another one the other way around.What did you expect to see?
It's a simple UDP ping-pong, so it should work just fine, no errors.
What did you see instead?
write udp [::]:11000->:11001: wsasendto: The requested address is not valid in its context
The text was updated successfully, but these errors were encountered: