aboutsummaryrefslogtreecommitdiff
path: root/Emby.Common.Implementations/Networking
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2017-03-08 02:24:30 -0500
committerGitHub <noreply@github.com>2017-03-08 02:24:30 -0500
commit23010f2980381a4b56e05620d4604cafc0e00043 (patch)
tree418b4ad6964c84d17ff9c33fa88b0e1a8bcacd34 /Emby.Common.Implementations/Networking
parent0ac0a09c806112ce82dcd23f43c7df9ff8b5531d (diff)
parent314b84ae9ef5a692144b0a3a178ddcbd393c9fb9 (diff)
Merge pull request #2516 from MediaBrowser/beta
Beta
Diffstat (limited to 'Emby.Common.Implementations/Networking')
-rw-r--r--Emby.Common.Implementations/Networking/NetworkManager.cs14
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>