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();
}