Re: How tocheck whether a Connection has been made - WeOnlyDo Discussion board

Re: How tocheck whether a Connection has been made (General questions)

by Dmitry Drozdov, Friday, March 21, 2014, 21:27 (3901 days ago) @ Kamal

the application created a number of SFTP() although I'm checking whether it's null.

if(sftp == null)
sftp = new SFTP(); //this is executed as many as the number of files, Why??!!

if(sftp.State != SFTP.Stated.Idle || sftp.State =! SFTP.States.Connecting)
sftp.Connect() //still execute this as many as the number of files!!!

is it because the sftp created has a unique number associated with it. if so, how can i prevent the system from being hanged due to the high number of connections made to the server?!!

if(sftp.State != SFTP.Stated.Idle || sftp.State =! SFTP.States.Connecting)
sftp.Connect() //still execute this as many as the number of files!!!

This means that it will connect if State = Disconnected which is what you want but also when State = Executing, ReceivingFile, SendingFile. Perhaps this is why you get too many connections.

Maybe
if(sftp.State == SFTP.States.Disconnected)
is all you need


Complete thread: