public override void Dispose() { if (this.IsDisposed) { return; } base.Dispose(); try { if (this.Error == ErrorCode.ERR_Success) { for (int i = 0; i < 4; i++) { this.Disconnect(); } } } catch (Exception) { // ignored } if (this.kcp != IntPtr.Zero) { Kcp.KcpRelease(this.kcp); this.kcp = IntPtr.Zero; } this.socket = null; this.memoryStream.Dispose(); }