mirror of
https://github.com/golang/go
synced 2024-11-26 03:57:57 -07:00
parent
946e2543f8
commit
0226690a9b
@ -208,25 +208,10 @@ func (fd *netFD) listenStream(laddr sockaddr, backlog int, ctrlFn func(string, s
|
|||||||
func (fd *netFD) listenDatagram(laddr sockaddr, ctrlFn func(string, string, syscall.RawConn) error) error {
|
func (fd *netFD) listenDatagram(laddr sockaddr, ctrlFn func(string, string, syscall.RawConn) error) error {
|
||||||
switch addr := laddr.(type) {
|
switch addr := laddr.(type) {
|
||||||
case *UDPAddr:
|
case *UDPAddr:
|
||||||
// We provide a socket that listens to a wildcard
|
|
||||||
// address with reusable UDP port when the given laddr
|
|
||||||
// is an appropriate UDP multicast address prefix.
|
|
||||||
// This makes it possible for a single UDP listener to
|
|
||||||
// join multiple different group addresses, for
|
|
||||||
// multiple UDP listeners that listen on the same UDP
|
|
||||||
// port to join the same group address.
|
|
||||||
if addr.IP != nil && addr.IP.IsMulticast() {
|
if addr.IP != nil && addr.IP.IsMulticast() {
|
||||||
if err := setDefaultMulticastSockopts(fd.pfd.Sysfd); err != nil {
|
if err := setDefaultMulticastSockopts(fd.pfd.Sysfd); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
addr := *addr
|
|
||||||
switch fd.family {
|
|
||||||
case syscall.AF_INET:
|
|
||||||
addr.IP = IPv4zero
|
|
||||||
case syscall.AF_INET6:
|
|
||||||
addr.IP = IPv6unspecified
|
|
||||||
}
|
|
||||||
laddr = &addr
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
|
Loading…
Reference in New Issue
Block a user