diff options
| author | Bond-009 <bond.009@outlook.com> | 2023-11-30 17:40:06 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-30 17:40:06 +0100 |
| commit | cc276838b4edbb67356b805952262c38e9c9cd19 (patch) | |
| tree | 8cb27ed0ba34fdd2d941f43c09ccc2be70c10abb /Emby.Server.Implementations/Net/SocketFactory.cs | |
| parent | cf80ea25413b75bbeddaef136fbeee33aa882a60 (diff) | |
| parent | e46e3be667c76ff9a242d7499aff83d2d10881ed (diff) | |
Merge pull request #10558 from barronpm/dlna-plugin2
Move DLNA to Plugin (Part 2)
Diffstat (limited to 'Emby.Server.Implementations/Net/SocketFactory.cs')
| -rw-r--r-- | Emby.Server.Implementations/Net/SocketFactory.cs | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/Emby.Server.Implementations/Net/SocketFactory.cs b/Emby.Server.Implementations/Net/SocketFactory.cs index 2bcd5eab2..a3484f43e 100644 --- a/Emby.Server.Implementations/Net/SocketFactory.cs +++ b/Emby.Server.Implementations/Net/SocketFactory.cs @@ -1,7 +1,5 @@ using System; -using System.Linq; using System.Net; -using System.Net.NetworkInformation; using System.Net.Sockets; using MediaBrowser.Model.Net; @@ -37,83 +35,5 @@ namespace Emby.Server.Implementations.Net throw; } } - - /// <inheritdoc /> - public Socket CreateSsdpUdpSocket(IPData bindInterface, int localPort) - { - var interfaceAddress = bindInterface.Address; - ArgumentNullException.ThrowIfNull(interfaceAddress); - - if (localPort < 0) - { - throw new ArgumentException("localPort cannot be less than zero.", nameof(localPort)); - } - - var socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); - try - { - socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); - socket.Bind(new IPEndPoint(interfaceAddress, localPort)); - - return socket; - } - catch - { - socket.Dispose(); - - throw; - } - } - - /// <inheritdoc /> - public Socket CreateUdpMulticastSocket(IPAddress multicastAddress, IPData bindInterface, int multicastTimeToLive, int localPort) - { - var bindIPAddress = bindInterface.Address; - ArgumentNullException.ThrowIfNull(multicastAddress); - ArgumentNullException.ThrowIfNull(bindIPAddress); - - if (multicastTimeToLive <= 0) - { - throw new ArgumentException("multicastTimeToLive cannot be zero or less.", nameof(multicastTimeToLive)); - } - - if (localPort < 0) - { - throw new ArgumentException("localPort cannot be less than zero.", nameof(localPort)); - } - - var socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); - - try - { - socket.MulticastLoopback = false; - socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); - socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.PacketInformation, true); - socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, multicastTimeToLive); - - if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()) - { - socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(multicastAddress)); - socket.Bind(new IPEndPoint(multicastAddress, localPort)); - } - else - { - // Only create socket if interface supports multicast - var interfaceIndex = bindInterface.Index; - var interfaceIndexSwapped = IPAddress.HostToNetworkOrder(interfaceIndex); - - socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(multicastAddress, interfaceIndex)); - socket.Bind(new IPEndPoint(bindIPAddress, localPort)); - } - - return socket; - } - catch - { - socket.Dispose(); - - throw; - } - } } } |
