diff --git a/src/MulticastService.cs b/src/MulticastService.cs index d01e3a0..ce44a14 100644 --- a/src/MulticastService.cs +++ b/src/MulticastService.cs @@ -161,6 +161,16 @@ public MulticastService(Func, IEnumerable public bool IgnoreDuplicateMessages { get; set; } + /// + /// Determines whether loopback interfaces should be excluded when other network interfaces are available + /// + /// + /// true to always include loopback interfaces. + /// false to only include loopback interfaces when no other interfaces exist. + /// Defaults to false. + /// + public static bool IncludeLoopbackInterfaces { get; set; } = false; + /// /// Get the network interfaces that are useable. /// @@ -182,7 +192,7 @@ public static IEnumerable GetNetworkInterfaces() { var nics = NetworkInterface.GetAllNetworkInterfaces() .Where(nic => nic.OperationalStatus == OperationalStatus.Up) - .Where(nic => nic.NetworkInterfaceType != NetworkInterfaceType.Loopback) + .Where(nic => IncludeLoopbackInterfaces || (nic.NetworkInterfaceType != NetworkInterfaceType.Loopback)) .ToArray(); if (nics.Length > 0) return nics;