Multiple connections (General questions)
Hello,
In a utility that I write, I have a loop that checks if a specific folder is exist on a unix server, and if not - then it checks again (on the unix server) with an added prefix to this folder (e.g: it checks for folder1, folder2, folder3 etc.).
I write it here because I found that the only way that it 100 works, is to open a connection in the first time, and on the next times - if the connection is already opened, so firstable I close it, and then re-open it:
[code]
If Form1.ssh.State = Connected Then
Form1.ssh.Disconnect
End If
' re-open again...
[/code]
I know that this way consumes lots of connections and may reduce the performance, so I would like to know if there is a better way to do it, because when I tried to reuse an opened connection (as the next example), it is not always working:
[code]If Form1.ssh.State = Disconnected Then
' connect (again) ...
End If
If Form1.ssh.State = Connected Then
' reuse the exist connection...
End If[/code]
I know that the SSH has another states, but I don't know how to handle with all the rest. Closing the connection (as I made in the first example) seems to always work.
I found no relevant data in the attached PDF.
As I said, if there is any better way - please let me know.
Thanks in advance!
Re: Multiple connections
Hi TG,
Can you tell me more information? What exactly do you mean when you say doesn't work . Do you receive an error? Which one?
Also, why don't you try using Blocking mode instead?
When using blocking mode, the code will wait until your current method is completed and then proceed with the code.
Regards,
Damba
Re: Multiple connections
Hi, Thanks.
I'm using the blocking mode. Here is what I use on the connecting:
<code>
Form1.ssh.Protocol = SSHAuto
Form1.ssh.Timeout = 60
Form1.ssh.Blocking = True
Form1.ssh.Connect
</code>
Later, I use waitfor and execute methods, and it seems to stuck in the waitfor method.
<code>
Form1.ssh.WaitFor( regex:[$ #>] $ )
Form1.ssh.Execute( /usr/bin/ls & path & vbCrLf, regex:[$ #>] $ , 30)
</code>
Can you tell me if you reuse the connection? And if yes - how do you do it?
Thanks again
Re: Multiple connections
TG,
You can still ignore that error are call Receiv method to retrieve anything that maybe arrived. Can you try?
However, i'm pretty certain that if issue occurs on WaitFor, are you 100 sure that the regex that you put in is correct? Can you try doing the same commands from some other client and check the prompt?
Regards,
Damba