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: Listen{,Packet,TCP,UDP,MulticastUDP,IP} can't bind to 255.255.255.255 #28798

Closed
Alan-Jowett opened this issue Nov 14, 2018 · 2 comments
Closed

Comments

@Alan-Jowett
Copy link

@Alan-Jowett Alan-Jowett commented Nov 14, 2018

What version of Go are you using (go version)?

go version go1.10.4 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/alan/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/alan/go"
GORACE=""
GOROOT="/usr/lib/go-1.10"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.10/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build812735178=/tmp/go-build -gno-record-gcc-switches"

What did you do?

lAddr, err := net.ResolveUDPAddr("udp", "255.255.255.255:48899")
if err != nil {
    log.Fatal(err)
}

_, err = net.ListenMulticastUDP("udp", nil, lAddr)
if err != nil {
    log.Fatal(err)
}

repro.go.txt

What did you expect to see?

net.ListenMulticastUDP succeeds

What did you see instead?

2018/11/14 11:44:40 listen udp 255.255.255.255:48899: bind: cannot assign requested address
exit status 1

@Alan-Jowett

This comment has been minimized.

Copy link
Author

@Alan-Jowett Alan-Jowett commented Nov 14, 2018

User error. Issue is broadcast is not the same a multi-cast.

@mikioh mikioh changed the title ListenMulticastUDP can't bind to 255.255.255.255 net: Listen{,Packet,MulticastUDP} can't bind to 255.255.255.255 Nov 15, 2018
@mikioh

This comment has been minimized.

Copy link
Contributor

@mikioh mikioh commented Nov 15, 2018

broadcast is not the same a multi-cast.

The syscall bind just books a protocol control block for the argument, and almost all the implementations (especially kernels have SO_BROADCAST-like options) will reject the booking with an IPv4 limited, or directed broadcast address because it connotes some ambiguity on IP packet routing.

@mikioh mikioh changed the title net: Listen{,Packet,MulticastUDP} can't bind to 255.255.255.255 net: Listen{,Packet,TCP,UDP,MulticastUDP,IP} can't bind to 255.255.255.255 Nov 21, 2018
@golang golang locked and limited conversation to collaborators Nov 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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.