public USocket(Action <BufferEntity> dispatchNetEvent) { udpClient = new UdpClient(0); server = new IPEndPoint(IPAddress.Parse(ip), port); local = new UClient(this, server, 0, 0, 0, dispatchNetEvent); ReceiveTask();//接收消息 }
/// <summary> /// 关闭udpClient /// </summary> public void Close() { if (local != null) { local = null; } if (udpClient != null) { udpClient.Close(); udpClient = null; } }