求助:udpclient释放后 UDPCLIENT.RECEIVE()数据仍然存在
当第一次运行线程关闭后,第二次再次运行此线程会直接运行MessageBox.Show("receivecommand终止"); 各位能帮忙解答吗?在下感激不尽,求各位大神帮忙,在下叩首谢恩了
代码如下:
程序代码:
private void Receivecommand()//??? { UdpClient local2 =Listencommandclient;//监控接受端口 Byte[] listendata=new byte[1024]; IPEndPoint remote2 = new IPEndPoint(IPAddress.Parse(chatIp), commamdNo);//监控发送端口 try { while (true) { listendata = local2.Receive(ref remote2); if (Encoding.Unicode.GetString(listendata, 0, listendata.Length) == "stop") { connectYesNo = false; chatIp = null; break; } } //local2.Close(); } catch (Exception ee) { local2.Close(); } local2.Close(); Thread.Sleep(100); MessageBox.Show("receivecommand终止"); }