go: net: ListenUDP doesn't work with ":port" or "0.0.0.0:port" on Windows
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)?
$ go env
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=D:\code\go
set GORACE=
set GOROOT=C:\go
set GOTOOLDIR=C:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
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
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 15 (12 by maintainers)
@toqueteos,
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.
@crvv,
Feel free to open a new issue for documentation improvement and send a CL.
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