aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Net
diff options
context:
space:
mode:
authorCody Robibero <cody@robibe.ro>2022-03-10 14:19:08 -0700
committerGitHub <noreply@github.com>2022-03-10 14:19:08 -0700
commita5ffde0e9c120c9addc5a4953760bece919ff677 (patch)
tree3226eb8a7354545b39efbd7c5559d674798e5881 /Emby.Server.Implementations/Net
parent96de01ce016e26cd7ee9a3f128613458fa8f180e (diff)
parent470d175f32aaae980cd301e6e5fc4b5a1630576d (diff)
Merge pull request #7432 from Bond-009/socketfactory
Diffstat (limited to 'Emby.Server.Implementations/Net')
-rw-r--r--Emby.Server.Implementations/Net/SocketFactory.cs20
1 files changed, 3 insertions, 17 deletions
diff --git a/Emby.Server.Implementations/Net/SocketFactory.cs b/Emby.Server.Implementations/Net/SocketFactory.cs
index fd3fc31c9..21795c8f8 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
}
/// <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,14 +80,7 @@ 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)
- {
- }
+ retVal.ExclusiveAddressUse = false;
try
{
@@ -114,7 +100,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);