From b9c12ca4a75a8efc4506b1711808931d77ed8c83 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 2 Mar 2017 23:36:20 -0500 Subject: update legacy stream --- Emby.Common.Implementations/Networking/NetworkManager.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'Emby.Common.Implementations/Networking') diff --git a/Emby.Common.Implementations/Networking/NetworkManager.cs b/Emby.Common.Implementations/Networking/NetworkManager.cs index 4485e8b14..2b84b2aa1 100644 --- a/Emby.Common.Implementations/Networking/NetworkManager.cs +++ b/Emby.Common.Implementations/Networking/NetworkManager.cs @@ -234,7 +234,7 @@ namespace Emby.Common.Implementations.Networking // Try to exclude virtual adapters // http://stackoverflow.com/questions/8089685/c-sharp-finding-my-machines-local-ip-address-and-not-the-vms var addr = ipProperties.GatewayAddresses.FirstOrDefault(); - if (addr == null|| string.Equals(addr.Address.ToString(), "0.0.0.0", StringComparison.OrdinalIgnoreCase)) + if (addr == null || string.Equals(addr.Address.ToString(), "0.0.0.0", StringComparison.OrdinalIgnoreCase)) { return new List(); } @@ -275,7 +275,7 @@ namespace Emby.Common.Implementations.Networking /// Gets a random port number that is currently available /// /// System.Int32. - public int GetRandomUnusedPort() + public int GetRandomUnusedTcpPort() { var listener = new TcpListener(IPAddress.Any, 0); listener.Start(); @@ -284,6 +284,16 @@ namespace Emby.Common.Implementations.Networking return port; } + public int GetRandomUnusedUdpPort() + { + IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, 0); + using (var udpClient = new UdpClient(localEndPoint)) + { + var port = ((IPEndPoint)(udpClient.Client.LocalEndPoint)).Port; + return port; + } + } + /// /// Returns MAC Address from first Network Card in Computer /// -- cgit v1.2.3