From 1d018c557599a544ad2f8193ce7cc0a6a6f1260a Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Tue, 8 Mar 2022 22:20:43 +0100 Subject: SocketFactory: Remove redundant code ExclusiveAddressUse should be false by default afaik --- Emby.Server.Implementations/Net/SocketFactory.cs | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'Emby.Server.Implementations/Net') diff --git a/Emby.Server.Implementations/Net/SocketFactory.cs b/Emby.Server.Implementations/Net/SocketFactory.cs index fd3fc31c9..58fa14948 100644 --- a/Emby.Server.Implementations/Net/SocketFactory.cs +++ b/Emby.Server.Implementations/Net/SocketFactory.cs @@ -1,5 +1,3 @@ -#nullable disable - #pragma warning disable CS1591 using System; @@ -63,18 +61,13 @@ namespace Emby.Server.Implementations.Net } /// - public ISocket CreateUdpMulticastSocket(string ipAddress, int multicastTimeToLive, int localPort) + public ISocket CreateUdpMulticastSocket(IPAddress ipAddress, int multicastTimeToLive, int localPort) { if (ipAddress == null) { throw new ArgumentNullException(nameof(ipAddress)); } - if (ipAddress.Length == 0) - { - throw new ArgumentException("ipAddress cannot be an empty string.", nameof(ipAddress)); - } - if (multicastTimeToLive <= 0) { throw new ArgumentException("multicastTimeToLive cannot be zero or less.", nameof(multicastTimeToLive)); @@ -87,15 +80,6 @@ namespace Emby.Server.Implementations.Net var retVal = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); - try - { - // not supported on all platforms. throws on ubuntu with .net core 2.0 - retVal.ExclusiveAddressUse = false; - } - catch (SocketException) - { - } - try { // seeing occasional exceptions thrown on qnap @@ -114,7 +98,7 @@ namespace Emby.Server.Implementations.Net var localIp = IPAddress.Any; - retVal.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Parse(ipAddress), localIp)); + retVal.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(ipAddress, localIp)); retVal.MulticastLoopback = true; return new UdpSocket(retVal, localPort, localIp); -- cgit v1.2.3 From 470d175f32aaae980cd301e6e5fc4b5a1630576d Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Thu, 10 Mar 2022 20:51:22 +0100 Subject: ExclusiveAddressUse: cheated by the docs --- Emby.Server.Implementations/Net/SocketFactory.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Emby.Server.Implementations/Net') diff --git a/Emby.Server.Implementations/Net/SocketFactory.cs b/Emby.Server.Implementations/Net/SocketFactory.cs index 58fa14948..21795c8f8 100644 --- a/Emby.Server.Implementations/Net/SocketFactory.cs +++ b/Emby.Server.Implementations/Net/SocketFactory.cs @@ -80,6 +80,8 @@ namespace Emby.Server.Implementations.Net var retVal = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); + retVal.ExclusiveAddressUse = false; + try { // seeing occasional exceptions thrown on qnap -- cgit v1.2.3