(PureBasic) Check SSH Connection (IsConnected)
Demonstrates how to check to see if the connection to the SSH server exists.
IncludeFile "CkSsh.pb"
Procedure ChilkatExample()
ssh.i = CkSsh::ckCreate()
If ssh.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; Connect to an SSH server:
success.i = CkSsh::ckConnect(ssh,"192.168.1.209",22)
If success <> 1
Debug CkSsh::ckLastErrorText(ssh)
CkSsh::ckDispose(ssh)
ProcedureReturn
EndIf
; Is the last known state "connected"?
connected.i = CkSsh::ckIsConnected(ssh)
If connected = 1
; Verify for sure by sending an ignore message.
connected = CkSsh::ckSendIgnore(ssh)
EndIf
Debug "connected = " + Str(connected)
; Disconnect.
CkSsh::ckDisconnect(ssh)
; Am I still connected?
connected = CkSsh::ckIsConnected(ssh)
Debug "connected = " + Str(connected)
CkSsh::ckDispose(ssh)
ProcedureReturn
EndProcedure
|