SocketFactory: Remove redundant code
ExclusiveAddressUse should be false by default afaik
This commit is contained in:
parent
03f1eff21a
commit
1d018c5575
|
@ -1,5 +1,3 @@
|
|||
#nullable disable
|
||||
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
|
@ -63,18 +61,13 @@ namespace Emby.Server.Implementations.Net
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
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);
|
||||
|
|
|
@ -26,6 +26,6 @@ namespace MediaBrowser.Model.Net
|
|||
/// <param name="multicastTimeToLive">The multicast time to live value. Actually a maximum number of network hops for UDP packets.</param>
|
||||
/// <param name="localPort">The local port to bind to.</param>
|
||||
/// <returns>A <see cref="ISocket"/> implementation.</returns>
|
||||
ISocket CreateUdpMulticastSocket(string ipAddress, int multicastTimeToLive, int localPort);
|
||||
ISocket CreateUdpMulticastSocket(IPAddress ipAddress, int multicastTimeToLive, int localPort);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -338,7 +338,7 @@ namespace Rssdp.Infrastructure
|
|||
|
||||
private ISocket ListenForBroadcastsAsync()
|
||||
{
|
||||
var socket = _SocketFactory.CreateUdpMulticastSocket(SsdpConstants.MulticastLocalAdminAddress, _MulticastTtl, SsdpConstants.MulticastPort);
|
||||
var socket = _SocketFactory.CreateUdpMulticastSocket(IPAddress.Parse(SsdpConstants.MulticastLocalAdminAddress), _MulticastTtl, SsdpConstants.MulticastPort);
|
||||
_ = ListenToSocketInternal(socket);
|
||||
|
||||
return socket;
|
||||
|
|
Loading…
Reference in New Issue
Block a user