Exemple #1
0
        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;
                    }
                }
            }
        }
Exemple #2
0
 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;
     }
 }
Exemple #3
0
        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();
        }