C# UDP如何理?
我在一按,出一窗Form2,
private void Form2_Load(object sender, EventArgs e)
{
GlobalUDP.UDPClient = new UdpClient();
GlobalUDP.EP = new IPEndPoint(IPAddress.Parse("255.255.255.255"), 26868);
IPEndPoint BindEP = new IPEndPoint(IPAddress.Any, 26868);
byte[] DiscoverMsg = Encoding.ASCII.GetBytes("Discovery:Who is out there?");
GlobalUDP.UDPClient.Client.Bind(BindEP);
GlobalUDP.UDPClient.MulticastLoopback = false;
GlobalUDP.UDPClient.EnableBroadcast = true;
//Configure ourself to receive discovery responses
GlobalUDP.UDPClient.BeginReceive(ReceiveCallback, GlobalUDP);
// Transmit the discovery request message
GlobalUDP.UDPClient.Send(DiscoverMsg, DiscoverMsg.Length, new System.Net.IPEndPoint(System.Net.IPAddress.Parse("255.255.255.255"), 26868));
}
Form2窗,再次Form2窗,出如下:
Only one usage of each socket address (protocol/network address/port) is normally permitted
教:在窗如何理?
[解决办法]
关注,UP上去
[解决办法]
在你关闭窗体时要把资源释放完