我的电脑上有两个脸。我通过我所有的面孔发送请求。但是我通过1 Iface接收数据。然而,在Wireshark,我通过所有的界面看到所有的数据。如果我循环遍历所有接口而不是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;
}发布于 2018-11-23 11:02:17
在我将应用程序访问到windows防火墙中的公用网络之后,它就可以工作了。
https://stackoverflow.com/questions/53442480
复制相似问题