static void Receive(ISearcher searcher, List <UdpClient> clients) { IPEndPoint received = new IPEndPoint(IPAddress.Parse("192.168.0.1"), 5351); foreach (UdpClient client in clients) { if (client.Available > 0) { IPAddress localAddress = ((IPEndPoint)client.Client.LocalEndPoint).Address; byte[] data = client.Receive(ref received); searcher.Handle(localAddress, data, received); } } }
static async Task Receive(ISearcher searcher, List <UdpClient> clients) { foreach (UdpClient client in clients) { if (client.Available > 0) { IPAddress localAddress = ((IPEndPoint)client.Client.LocalEndPoint).Address; var result = await client.ReceiveAsync().ConfigureAwait(false); var data = result.Buffer; var received = result.RemoteEndPoint; searcher.Handle(localAddress, data, received); } } }
private static void Receive(ISearcher searcher, List <UdpClient> clients) { IPEndPoint received = new IPEndPoint(IPAddress.Parse("192.168.8.1"), 5351); foreach (UdpClient client in clients) { #if SSHARP if (client.DataAvailable) #else if (client.Available > 0) #endif { #if SSHARP IPAddress localAddress = ((IPEndPoint)client.LocalEndPoint).Address; #else IPAddress localAddress = ((IPEndPoint)client.Client.LocalEndPoint).Address; #endif byte[] data = client.Receive(ref received); searcher.Handle(localAddress, data, received); } } }
static void Receive (ISearcher searcher, List<UdpClient> clients) { IPEndPoint received = new IPEndPoint(IPAddress.Parse("192.168.0.1"), 5351); foreach (UdpClient client in clients) { if (client.Available > 0) { IPAddress localAddress = ((IPEndPoint)client.Client.LocalEndPoint).Address; byte[] data = client.Receive(ref received); searcher.Handle(localAddress, data, received); } } }