-1
我嘗試PLC(電子設備)和PC之間的通信。防火牆關閉。我看到wireshark收到的包裹。C#UDP客戶recive太慢
問題1:接收messagges太慢,爲什麼呢?它需要幾次才能到達我的代碼。我的代碼如下。
問題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);
}