using System; using System.Net; using System.Threading; using System.Threading.Tasks; namespace LanDiscovery.Services { public class NameResolutionService { private const int MaxConcurrency = 32; public async Task ResolveHostnameAsync(string ipAddress) { if (string.IsNullOrEmpty(ipAddress)) return ""; try { // This can be slow, so it should be called concurrently but throttled // We'll trust the Orchestrator or UI to not call this 254 times instantly on one thread. // Or better, we throttle internally if we were processing a list. // For per-item calls, simple async is fine, the calling side should manage limits. var entry = await Dns.GetHostEntryAsync(ipAddress); return entry.HostName ?? ""; } catch (Exception) { // DNS resolution failed or timeout return ""; } } // NetBIOS would go here using UDP 137 queries standard. // For MVP we stick to DNS. } }