diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2017-03-02 23:36:20 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2017-03-02 23:36:20 -0500 |
| commit | b9c12ca4a75a8efc4506b1711808931d77ed8c83 (patch) | |
| tree | c73f024c3df193e9bd9b32c9228274d0e97fa2e4 /Emby.Common.Implementations/Networking/NetworkManager.cs | |
| parent | 0a64609fb8cffa0a40a9b832ae700f607ea34e58 (diff) | |
update legacy stream
Diffstat (limited to 'Emby.Common.Implementations/Networking/NetworkManager.cs')
| -rw-r--r-- | Emby.Common.Implementations/Networking/NetworkManager.cs | 14 |
1 files changed, 12 insertions, 2 deletions
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<IPAddress>(); } @@ -275,7 +275,7 @@ namespace Emby.Common.Implementations.Networking /// Gets a random port number that is currently available /// </summary> /// <returns>System.Int32.</returns> - 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; + } + } + /// <summary> /// Returns MAC Address from first Network Card in Computer /// </summary> |
