How tocheck whether a Connection has been made?! - WeOnlyDo Discussion board

How tocheck whether a Connection has been made?! (wodSFTP / wodSFTP.NET / wodSFTPdll)

by Kamal, Monday, January 10, 2005, 17:15 (7054 days ago)

Hi,

I need to be able to check whether the sftp.Connect() method has already been fired.? How can I do that pleasee?

Thank you and waiting for your response.

Re: How tocheck whether a Connection has been made

by wodSupport, Monday, January 10, 2005, 20:06 (7054 days ago) @ Kamal

Kamal,

can you check if State property is Connecting or Connected?

Re: How tocheck whether a Connection has been made

by Kamal, Tuesday, January 11, 2005, 12:21 (7053 days ago) @ wodSupport

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?!!

Re: How tocheck whether a Connection has been made

by wodSupport, Tuesday, January 11, 2005, 13:15 (7053 days ago) @ Kamal

I'm sorry, but I'm not following you. I don't understand the problem at all. Can you zip your project or sample of the project that has these problems and email it to techsupport@weonlydo.com ?

Re: How tocheck whether a Connection has been made

by Kamal, Tuesday, January 11, 2005, 18:17 (7053 days ago) @ wodSupport

all i want to know is whether it is true that a connection has to be made for each file in the list of files you want to transmit or not?!

and if that's not true then is there a way around it or how do you go about creating only one connection to transmit a set of files..??

thank you.

Re: How tocheck whether a Connection has been made

by wodSupport, Tuesday, January 11, 2005, 18:19 (7053 days ago) @ Kamal

Kamal,

no, once you Connect you can call as many PutFile/GetFile methods as you want in the same connection - but one at a time.

Hope it helps.

Re: How tocheck whether a Connection has been made

by Kamal, Wednesday, January 12, 2005, 11:12 (7052 days ago) @ wodSupport

i've sent 10 files using wodsftp.NET and when using the command (netstat) from the Commandline to see the number of connections made, it showed that there are 10 connections using Port 22?!

is that what it suppose to display, or am I wrong?!


snapshot of what netstat displayed:

-----------------------------------------------------------

C:
etstat

Active Connections

Proto LocalAddress ForeignAddress State
TCP testm:1140 remoteserverName:22 ESTABLISHED
TCP testm:1141 remoteserverName:22 ESTABLISHED
TCP testm:1143 remoteserverName:22 ESTABLISHED
-----------------------------------------------------------

Thank you, your help and support are highly appreciated.


Kamal

Re: How tocheck whether a Connection has been made

by wodSupport, Wednesday, January 12, 2005, 11:53 (7052 days ago) @ Kamal

Kamal,

how many times do you call Connect method?

Re: How tocheck whether a Connection has been made

by Kamal, Wednesday, January 12, 2005, 13:35 (7052 days ago) @ wodSupport

it seems to fire the connect() method for each file although i check the state before connecting whether it is idle or Connecting and if it is not then execute it but it seems to ignore it and execute it anyhow!

and similar with SFTP, i check whether it is NULL or not and if it is not null then create a new one sftp = new SFTP() but it seems to ignore it and create a new one for each file anyhow!

is that because each single file has it's own GUID? or is that something else.?!! [:doh:]

Re: How tocheck whether a Connection has been made

by wodSupport, Wednesday, January 12, 2005, 20:18 (7052 days ago) @ Kamal

Kamal,

sorry, but I really don't know what to say. Component cannot create itself - you must create it. It cannot call 'Connect' by itself - you must call it. So, I believe answer to 'why there are multiple connections' should be somewhere in your code. I really can't help you here, I don't see your code, sorry.

Kreso

Re: How tocheck whether a Connection has been made

by Dmitry Drozdov, Friday, March 21, 2014, 21:27 (3696 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