mirror of
https://github.com/golang/go
synced 2024-11-12 08:50:22 -07:00
net: enable UDP broadcast before it is needed (instead of after)
Fixes #526. R=r CC=golang-dev https://golang.org/cl/186211
This commit is contained in:
parent
16205a3534
commit
7c1bb00374
@ -35,6 +35,9 @@ func socket(net string, f, p, t int, la, ra syscall.Sockaddr, toAddr func(syscal
|
||||
// Allow reuse of recently-used addresses.
|
||||
syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1)
|
||||
|
||||
// Allow broadcast.
|
||||
syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_BROADCAST, 1)
|
||||
|
||||
if la != nil {
|
||||
e = syscall.Bind(s, la)
|
||||
if e != 0 {
|
||||
|
@ -71,11 +71,7 @@ type UDPConn struct {
|
||||
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 }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user