Reputation: 326
I have 2 Ifaces on my PC. I send a request through all Ifaces. But I receive data through 1 Iface. However, in Wireshark I see all data through all Ifaces. This works if I loop through all the interfaces instead IPAddress.Any.
public static List<byte[]> ReceiveArrayData(int port, byte response, int timeout)
{
byte[] data;
List<byte[]> result = new List<byte[]>();
UdpClient udpClient = new UdpClient(port);
IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0);
Stopwatch sw = new Stopwatch();
sw.Start();
while (true)
{
if (udpClient.Available > 0)
{ // получаем данные
data = udpClient.Receive(ref RemoteIpEndPoint);
if (data[0] == response)
{
result.Add(data);
System.Console.WriteLine(Functions.ByteArrayToString(data));
}
}
if (sw.ElapsedMilliseconds > timeout)
{
break;
}
}
udpClient.Close();
return result;
}
Upvotes: 0
Views: 598
Reputation: 326
It works after I added my application access to public network in windows firewall
Upvotes: 1