//关闭 public void Close(string msg) { lock (this) { if (!isDispose) { isDispose = true; try { Debug.Log("关闭Tcp Socket:" + msg); try { socket.Close(); } catch { } IDisposable disposable = socket; if (disposable != null) { disposable.Dispose(); } IDisposable disposableThis = this; buffers = null; if (disposableThis != null) { disposableThis.Dispose(); } client.Stop(); } catch (Exception) { } } } }
//关闭 public void Close(string msg) { lock (this) { if (!isDispose) { isDispose = true; try { Debug.Log("关闭连接远程EndPoint:" + socket.RemoteEndPoint.ToString() + " 本地EndPoint:" + socket.LocalEndPoint.ToString()); Debug.Log("关闭Tcp Socket:" + msg); try { socket.Close(); } catch { } IDisposable disposable = socket; if (disposable != null) { disposable.Dispose(); } IDisposable disposableThis = this; buffers = null; if (disposableThis != null) { disposableThis.Dispose(); } client.Stop(); } catch (Exception) { } } } }