我尝试在 PLC(电子设备)和 PC 之间进行通信。防火墙关闭。我看到了wireshark收到的包裹。
问题1:接收消息太慢,为什么?到达我的代码需要一些时间。我的代码如下。
问题 2:WireShark 软件如何快速捕获此消息?我怎样才能在 C# 中实现这一点?
问题3:我必须关闭防火墙才能接收消息。但是wireshark不需要关闭防火墙。我怎样才能通过永不关闭防火墙来实现这一点。我基本上尝试 1 对 1 的本地通信。
private void udpcommincate()
{
sock_rcv = new UdpClient(6002);
try
{
sock_rcv.BeginReceive(new AsyncCallback(recv), null);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
private void recv(IAsyncResult res)
{
IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 6002);
plc_gelen = sock_rcv.EndReceive(res, ref RemoteIpEndPoint);
flag= BitConverter.ToInt32(plc_gelen, 0);
sock_rcv.BeginReceive(new AsyncCallback(recv), null);
}