server: fix multicast listen error on Windows (https://github.com/aler9/rtsp-simple-server/issues/742)

This happened when the system has network interfaces that don't support multicast.
This commit is contained in:
aler9
2022-01-28 00:24:08 +01:00
parent 88e1244e9f
commit f2c1b88453

View File

@@ -108,9 +108,11 @@ func newServerUDPListener(
listenIP = net.ParseIP(host)
for _, intf := range intfs {
err := p.JoinGroup(&intf, &net.UDPAddr{IP: listenIP})
if err != nil {
return nil, err
if (intf.Flags & net.FlagMulticast) != 0 {
err := p.JoinGroup(&intf, &net.UDPAddr{IP: listenIP})
if err != nil {
return nil, err
}
}
}