Tamir.SharpSsh.jsch.Session.disconnect C# (CSharp) Method

disconnect() public method

public disconnect ( ) : void
return void
		public void disconnect()
		{
			if(!_isConnected) return;

			//System.Console.WriteLine(this+": disconnect");
			//Thread.dumpStack();
			/*
			for(int i=0; i<Channel.pool.size(); i++){
			  try{
				Channel c=((Channel)(Channel.pool.elementAt(i)));
			if(c.session==this) c.eof();
			  }
			  catch(Exception e){
			  }
			}
			*/

			Channel.disconnect(this);

			_isConnected=false;

			PortWatcher.delPort(this);
			ChannelForwardedTCPIP.delPort(this);

			lock(connectThread)
			{
				//System.Threading.Thread.Yield();
				//connectThread.yield();
				connectThread.Interrupt();
				connectThread=null;
			}
			thread=null;
			try
			{
				if(io!=null)
				{
					if(io.ins!=null) io.ins.Close();
					if(io.outs!=null) io.outs.Close();
					if(io.outs_ext!=null) io.outs_ext.Close();
				}
				if(proxy==null)
				{
					if(socket!=null)
						socket.Close();
				}
				else
				{
					lock(proxy)
					{
						proxy.close();
					}
					proxy=null;
				}
			}
			catch(Exception)
			{
				//      e.printStackTrace();
			}
			io=null;
			socket=null;
			//    lock(jsch.pool){
			//      jsch.pool.removeElement(this);
			//    }

			jsch.removeSession(this);

			//System.gc();
		}

Usage Example

Example #1
0
        public void releaseSession(Session session)
        {
            if (session == null)
                throw new System.ArgumentNullException ("session");

            if (session.isConnected())
                session.disconnect();
        }
All Usage Examples Of Tamir.SharpSsh.jsch.Session::disconnect