-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
udp broadcast #526
Labels
Comments
The pointer part isn't the problem. udpsock calls setsockoptInt, which (in syscall/syscall_linux.go's SetsockoptInt) does in fact pass a pointer to the system call. I don't know what the problem is, though. If you'd like to investigate the source is in src/pkg/net and src/pkg/syscall. Owner changed to r...@golang.org. Status changed to HelpWanted. |
Comment 7 by graycardinalster: broken_bcast2.go: dial udp4 192.168.111.255:666: permission denied Attachments:
|
This seems to be linux specific. for broken_bcast2.go strace suggests that this error is because connect() is called before SO_BROADCAST is set. this is probably not the best solution, but you could try: --- a/src/pkg/net/sock.go Sat Jan 09 09:47:45 2010 -0800 +++ b/src/pkg/net/sock.go Sat Jan 16 01:43:42 2010 +0000 @@ -35,6 +35,9 @@ // Allow reuse of recently-used addresses. syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1) + // For UDP Broadcasts on linux + setsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_BROADCAST, 1) + if la != nil { e = syscall.Bind(s, la) if e != 0 { |
the following fixes it for me: diff -r 1f997563b819 src/pkg/net/sock.go --- a/src/pkg/net/sock.go Fri Jan 15 14:02:53 2010 -0800 +++ b/src/pkg/net/sock.go Sat Jan 16 07:56:41 2010 +0000 @@ -35,6 +35,11 @@ // Allow reuse of recently-used addresses. syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1) + switch net { + case "udp", "udp4": + syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_BROADCAST, 1) + } + if la != nil { e = syscall.Bind(s, la) if e != 0 { diff -r 1f997563b819 src/pkg/net/udpsock.go --- a/src/pkg/net/udpsock.go Fri Jan 15 14:02:53 2010 -0800 +++ b/src/pkg/net/udpsock.go Sat Jan 16 07:56:41 2010 +0000 @@ -71,11 +71,7 @@ fd *netFD } -func newUDPConn(fd *netFD) *UDPConn { - c := &UDPConn{fd} - setsockoptInt(fd.sysfd, syscall.SOL_SOCKET, syscall.SO_BROADCAST, 1) - return c -} +func newUDPConn(fd *netFD) *UDPConn { return &UDPConn{fd} } func (c *UDPConn) ok() bool { return c != nil && c.fd != nil } |
This issue was closed by revision 7c1bb00. Status changed to Fixed. Merged into issue #-. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by graycardinalster:
Attachments:
The text was updated successfully, but these errors were encountered: