diff options
| author | Patrick Barron <barronpm@gmail.com> | 2023-11-09 15:57:19 -0500 |
|---|---|---|
| committer | Patrick Barron <barronpm@gmail.com> | 2023-11-15 20:54:03 -0500 |
| commit | e46e3be667c76ff9a242d7499aff83d2d10881ed (patch) | |
| tree | 017798ef59893470532e9133dd45b399f310fd73 | |
| parent | a8c55ae8fec58b3aacd1cf311a8ac9c2dda503ff (diff) | |
Remove DLNA socket code
| -rw-r--r-- | Emby.Server.Implementations/Net/SocketFactory.cs | 80 | ||||
| -rw-r--r-- | MediaBrowser.Model/Net/ISocketFactory.cs | 18 |
2 files changed, 0 insertions, 98 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; - } - } } } diff --git a/MediaBrowser.Model/Net/ISocketFactory.cs b/MediaBrowser.Model/Net/ISocketFactory.cs index 128034eb8..62b87d9f5 100644 --- a/MediaBrowser.Model/Net/ISocketFactory.cs +++ b/MediaBrowser.Model/Net/ISocketFactory.cs @@ -14,22 +14,4 @@ public interface ISocketFactory /// <param name="localPort">The local port to bind to.</param> /// <returns>A new unicast socket using the specified local port number.</returns> Socket CreateUdpBroadcastSocket(int localPort); - - /// <summary> - /// Creates a new unicast socket using the specified local port number. - /// </summary> - /// <param name="bindInterface">The bind interface.</param> - /// <param name="localPort">The local port to bind to.</param> - /// <returns>A new unicast socket using the specified local port number.</returns> - Socket CreateSsdpUdpSocket(IPData bindInterface, int localPort); - - /// <summary> - /// Creates a new multicast socket using the specified multicast IP address, multicast time to live and local port. - /// </summary> - /// <param name="multicastAddress">The multicast IP address to bind to.</param> - /// <param name="bindInterface">The bind interface.</param> - /// <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 new multicast socket using the specfied bind interface, multicast address, multicast time to live and port.</returns> - Socket CreateUdpMulticastSocket(IPAddress multicastAddress, IPData bindInterface, int multicastTimeToLive, int localPort); } |
