How to ensure TScSSHClient and TMyConnection both open and / or close at the same time

How to ensure TScSSHClient and TMyConnection both open and / or close at the same time

I like the way opening a TMyQuery automatically opens the TMyConnection that it is connected to.

Does TScSSHClient do the same thing?

ie
if I have TMyConnection. IOhandler -> TScFileStorage.Client -> TScSSHClient 
will calling TMyConnection.Connect automatically call TScSSHClient.connect and vice versa,
ie does TScSSHClient.Connect call  TMyConnection.Connect, or must I do each one by hand?

If so does the order matter? TScSSHClient first or TMyConnection first?

Same question for disconnection ie does disconnecting one component automatically disconnect the other ?

I ask as in order to shut down my application gracefully I set TMyConnection.BeforeDisconnect to point to a procedure that called TScSSHClient.disconnect but that gave me a stack overflow  and I had to do the two operations separately by hand in the onclose event of the form, so I wondered if disconnect calls were being made recursively due to some automatic action within the components.

Further info...

I've done some experimentation and it seems that even without using the OnBeforeConnect or OnBeforeDisconnect methods, starting with both components disconnected, calling TMyConnection.Connect automatically calls TScSSHClient.Connect (but not vice versa)

 

and with both components connected, calling calling TScSSHClient.Disconnect automatically calls TMyConnection.Disconnect (but not vice versa)

 

Also depending on the order of connection / disconnection the traffic may be encrypted , not encrypted or not possible.

 

I made the table below. Can anyone confirm if this logic is correct, and if it's not correct please can you make it correct for me.

 

Note this is without using any OnBefore/ OnAfter connect or  disconnect methods, just linking the components together.

starting state

 

operation

endting state

traffic

TScSSHClient

TMyConnection

 

 

TScSSHClient

TMyConnection

 

disconnected

disconnected

no traffic

TMyConnection.Connect

connected

connected

encryted traffic

disconnected

disconnected

no traffic

TScSSHClient.Connect

connected

disconnected

no traffic

connected

disconnected

no traffic

TMyConnection.Connect

connected

connected

un encrypted traffic

disconnected

connected

not a possible starting state as connecting TMyConnection also connects TScSSHClient

 

 

 

 

 

 

 

connected

connected

#

TMyConnection.DisConnect

connected

disconnected

no traffic

connected

connected

#

TScSSHClient.DisConnect

disconnected

disconnected

no traffic

connected

disconnected

no traffic

TScSSHClient.DisConnect

disconnected

disconnected

no traffic

disconnected

connected

not a possible starting state as connecting TMyConnection also connects TScSSHClient

#

Either encryted or un encrypted trafic depending upon which component was connected first