public void close() { if (_clozed) { return; } _clozed = true; Ctrl.debugLogForIO("socketContentClose"); doClose(); }
private void onSocketConnect(IAsyncResult result) { bool isError = false; try { _socket.EndConnect(result); } catch (Exception e) { // Ctrl.printExceptionForIO(e); isError = true; } try { EndPoint localEndPoint = _socket.LocalEndPoint; if (localEndPoint != null) { Ctrl.debugLogForIO("本地端口:", localEndPoint.Serialize().ToString(), doIndex); } } catch (Exception e) { Ctrl.printExceptionForIO(e); } Ctrl.debugLogForIO("socketContent连接结果,success:", !isError, this.GetHashCode()); ThreadControl.addMainFunc(() => { if (isError) { connectFailedOnce(); } else { connectSuccess(); } }); }
/** 即将关闭(IO线程) */ protected void preBeClose(int way) { // Ctrl.debugLogForIO("preBeClose",way); doClose(); if (_clozed) { return; } _clozed = true; Ctrl.debugLogForIO("preBeClose2", way, this.GetHashCode()); ThreadControl.addMainFunc(() => { if (checkIsCurrent()) { _parent.beClose(); } }); }