From a7dcf7191a71bfefd4a8c69d24d2eec53973bb83 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 17 Aug 2017 16:19:02 -0400 Subject: add fixes for .net core --- Emby.Server.Implementations/Net/SocketFactory.cs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'Emby.Server.Implementations/Net/SocketFactory.cs') diff --git a/Emby.Server.Implementations/Net/SocketFactory.cs b/Emby.Server.Implementations/Net/SocketFactory.cs index ab3bd0b31..f78fbdfd7 100644 --- a/Emby.Server.Implementations/Net/SocketFactory.cs +++ b/Emby.Server.Implementations/Net/SocketFactory.cs @@ -69,8 +69,8 @@ namespace Emby.Server.Implementations.Net if (remotePort < 0) throw new ArgumentException("remotePort cannot be less than zero.", "remotePort"); var addressFamily = remoteAddress.AddressFamily == IpAddressFamily.InterNetwork - ? AddressFamily.InterNetwork - : AddressFamily.InterNetworkV6; + ? AddressFamily.InterNetwork + : AddressFamily.InterNetworkV6; var retVal = new Socket(addressFamily, System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp); @@ -82,7 +82,7 @@ namespace Emby.Server.Implementations.Net { // This is not supported on all operating systems (qnap) } - + try { return new UdpSocket(retVal, new IpEndPointInfo(remoteAddress, remotePort)); @@ -139,11 +139,11 @@ namespace Emby.Server.Implementations.Net throw; } } - + /// - /// Creates a new UDP acceptSocket that is a member of the SSDP multicast local admin group and binds it to the specified local port. - /// - /// An implementation of the interface used by RSSDP components to perform acceptSocket operations. + /// Creates a new UDP acceptSocket that is a member of the SSDP multicast local admin group and binds it to the specified local port. + /// + /// An implementation of the interface used by RSSDP components to perform acceptSocket operations. public ISocket CreateSsdpUdpSocket(IpAddressInfo localIpAddress, int localPort) { if (localPort < 0) throw new ArgumentException("localPort cannot be less than zero.", "localPort"); @@ -186,7 +186,16 @@ namespace Emby.Server.Implementations.Net try { + // not supported on all platforms. throws on ubuntu with .net core 2.0 retVal.ExclusiveAddressUse = false; + } + catch (SocketException) + { + + } + + try + { //retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true); retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); retVal.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, multicastTimeToLive); -- cgit v1.2.3