|
|
|
@ -20,6 +20,7 @@ namespace Emby.Server.Implementations.Net
|
|
|
|
|
var retVal = new Socket(AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Dgram, System.Net.Sockets.ProtocolType.Udp);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
retVal.EnableBroadcast = true;
|
|
|
|
|
retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
|
|
|
|
|
retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 1);
|
|
|
|
|
|
|
|
|
@ -47,6 +48,7 @@ namespace Emby.Server.Implementations.Net
|
|
|
|
|
var retVal = new Socket(AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Dgram, System.Net.Sockets.ProtocolType.Udp);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
retVal.EnableBroadcast = true;
|
|
|
|
|
retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
|
|
|
|
|
retVal.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, 4);
|
|
|
|
|
|
|
|
|
@ -68,7 +70,7 @@ namespace Emby.Server.Implementations.Net
|
|
|
|
|
/// <param name="multicastTimeToLive">The multicast time to live value for the acceptSocket.</param>
|
|
|
|
|
/// <param name="localPort">The number of the local port to bind to.</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public ISocket CreateUdpMulticastSocket(string ipAddress, int multicastTimeToLive, int localPort, ILogger _logger)
|
|
|
|
|
public ISocket CreateUdpMulticastSocket(string ipAddress, int multicastTimeToLive, int localPort)
|
|
|
|
|
{
|
|
|
|
|
if (ipAddress == null)
|
|
|
|
|
{
|
|
|
|
@ -90,8 +92,6 @@ namespace Emby.Server.Implementations.Net
|
|
|
|
|
throw new ArgumentException("localPort cannot be less than zero.", nameof(localPort));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_logger.LogError("Created");
|
|
|
|
|
|
|
|
|
|
var retVal = new Socket(AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Dgram, System.Net.Sockets.ProtocolType.Udp);
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
@ -103,8 +103,6 @@ namespace Emby.Server.Implementations.Net
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_logger.LogError("Exclusive false");
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// seeing occasional exceptions thrown on qnap
|
|
|
|
@ -115,14 +113,9 @@ namespace Emby.Server.Implementations.Net
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_logger.LogError("Reused");
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
retVal.EnableBroadcast = true; // CHANGE
|
|
|
|
|
|
|
|
|
|
_logger.LogError("Broadcast");
|
|
|
|
|
|
|
|
|
|
retVal.EnableBroadcast = true;
|
|
|
|
|
// retVal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true);
|
|
|
|
|
retVal.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, multicastTimeToLive);
|
|
|
|
|
|
|
|
|
@ -130,9 +123,6 @@ namespace Emby.Server.Implementations.Net
|
|
|
|
|
|
|
|
|
|
retVal.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Parse(ipAddress), localIp));
|
|
|
|
|
retVal.MulticastLoopback = true;
|
|
|
|
|
|
|
|
|
|
_logger.LogError("Sorted");
|
|
|
|
|
|
|
|
|
|
return new UdpSocket(retVal, localPort, localIp);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|