private void Run() { _tcpConnected = false; _succeeded = false; _socket = null; try { _addressSet = null; _errorMessage = null; MakeConnection(); Debug.Assert(_socket != null); _errorMessage = null; Negotiate(); _succeeded = true; ////ProtocolUtil.FireConnectionSucceeded((ITerminalParameter)_tcpDestination); //_client.SuccessfullyExit(this.Result); } catch (Exception ex) { if (!_interrupted) { RuntimeUtil.DebuggerReportException(ex); if (!_overridingErrorMessage) { _errorMessage = ex.Message; } ////ProtocolUtil.FireConnectionFailure((ITerminalParameter)_tcpDestination, _errorMessage); //_client.ConnectionFailed(_errorMessage); } } finally { if (!_interrupted) { if (!_succeeded && _socket != null && _socket.Connected) { try { _socket.Shutdown(SocketShutdown.Both); //Close()‚¾‚Æ”ñ“¯ŠúŽóM‚µ‚Ä‚éꊂő¦Exception‚É‚È‚Á‚Ä‚µ‚Ü‚¤ } catch (Exception ex) { //‚±‚±‚Å‚¿‚á‚ñ‚ƕ‚¶‚邱‚Æ‚ªo—ˆ‚È‚¢ê‡‚ª‚ ‚Á‚½ RuntimeUtil.SilentReportException(ex); } } //‚±‚±‚Å‘Ò‹@‚µ‚Ä‚¢‚½ƒXƒŒƒbƒh‚ª“®‚«o‚·‚Ì‚ÅA‚»‚Ì‘O‚ÉSocket‚ÌDisconnect‚Í‚â‚Á‚‚¯‚Ä‚¨‚B“¯Žž‚ɂ‚‚¢‚½‚¹‚¢‚©ƒ\ƒPƒbƒg‚Ì“®ì‚ª–‚É‚È‚Á‚½ƒP[ƒX‚ ‚èB NotifyAsyncClient(); if (_NetUtil != null) { _NetUtil = null; } } } }
public void Interrupt() { _interrupted = true; //Ú‘±ƒXƒŒƒbƒh‚ªƒuƒƒbƒN‚µ‚Ä‚¢‚½‚è’ÊM’†‚Å‚ ‚Á‚Ä‚àAƒ\ƒPƒbƒg‚ð•Â‚¶‚Ä‚µ‚Ü‚¦‚΂·‚®—áŠO‚É‚È‚é‚Í‚¸‚Å‚ ‚èA //‰º‚ÌRun()‚Ìcatch‚ÆfinallyƒuƒƒbƒN‚ªŽÀs‚³‚ê‚éB if (_socket != null) { _socket.Close(); } if (_NetUtil != null) { _NetUtil = null; } }
public void AsyncConnect(IInterruptableConnectorClient client, ITCPParameter param) { _client = client; _tcpDestination = param; _host = param.Destination; _port = param.Port; _NetUtil = new NetUtil(_client.ConMain); ////AgentForward“™‚̃`ƒFƒbƒN‚ð‚·‚é //foreach(IConnectionResultEventHandler ch in ProtocolsPlugin.Instance.ConnectionResultEventHandler.GetExtensions()) // ch.BeforeAsyncConnect((ITerminalParameter)param.GetAdapter(typeof(ITerminalParameter))); Thread th = new Thread(new ThreadStart(this.Run)); th.Start(); }