public bool Listen() { this.SecurityKeys = SecurityFactory.GenerateKeys(); if (_client != null) { _client.Close(); } _client = new UdpClientEx(_context) { Port = this.Port, IP = this.IP, SecurityKeys = SecurityKeys }; _client.SendPacket += this.SendPacketEvent; _client.ReceivePacket += this.ReceivePacketEvent; //监听端口开始收信 if (!_client.Listen()) { return(false); } //文件或者大图片发送监听启动 if (_fileTransTcpListener != null) { _fileTransTcpListener.Close(); } _fileTransTcpListener = new FileTransportTcpListener(_context); _fileTransTcpListener.SecurityKeys = this.SecurityKeys; _fileTransTcpListener.ProgressChanged += FileSendProgressChanged; _fileTransTcpListener.Completed += FileSendCompleted; _fileTransTcpListener.Error += FileSendError; _fileTransTcpListener.Listen(IP, this.Port); return(true); }