Thanks for the reply Lee, but I see half my question is gone. How would I wait for the connected event? If you have an example I can understand your answer better.
Well, I typed up a question re jkSSH2, then figured it out before submitting. Typed a new question, under the wrong jkSSH2 title. Edited that one to say "please delete". I started over with this title and I thought I copied the text to this new correctly titled question, but I guess not. So I see it doesn't make a lot of sense.
The most important part of my question is missing, where I say I've been working with B4A for 3 days (4 now). So I went through the beginner's guide to the point of making buttons, just to flesh out the basic requirements. Then I look for examples & other users questions to find code that could be adapted for what I want to do. I bought it a few years ago, but at the time it looked too hard to learn so I went back to AI. That was ok, since I used SL4A to make up for it's limitations. But now I writing this for Android X86 kitkat, and SL4A does not work. So I'm trying B4A and finding it not as hard as I thought it would be.
I'm trying to start a VM on an ESXi server with SSH. This works
Then I launch VNC to the VM. But it can be sometimes up to 1 min or more after sending the power.on before the VNC port is actually available. So I want to avoid any "can't connect" error, I want to check if the port is open first before launching VNC.
I'm using Sockets to check if the port is open, if it returns true it launches VNC. But it only does it once, and sometimes fails. I want it to wait until the port is open and then launch VNC.
Here's my code again: (Please remember I pieced this together from examples & other questions, so I could be WAY off)
Sub Button6_Click
'Dim Intent2 As Intent
'Dim pm As PackageManager
Dim Socket88 As Socket
'Dim Socket1_Connected As Boolean
SSH2.initialize("SSH", "192.168.1.111", 22)
user = "root"
password = "password"
myKey = File.ReadString(File.DirAssets, "ssh-cert.pem")
DisableStrictMode
SSH2.authenticateWithKey(user,myKey, password)
SSH2.execCommand("vim-cmd vmsvc/power.on 88", 10)
Socket88.Initialize("Socket88")
Socket88.Connect("192.168.1.111", 5988 , 3000 )
End Sub
Sub VNC88
Dim Intent2 As Intent
Dim pm As PackageManager
Intent2 = pm.GetApplicationIntent ("com.iiordanov.bVNC")
Intent2.Initialize("android.intent.action.MAIN", "vnc://192.168.1.111:5988")
Intent2.SetComponent("com.iiordanov.bVNC/.RemoteCanvasActivity")
StartActivity (Intent2)
End Sub
Sub Socket88_Connected(Connected As Boolean)As Boolean
Dim Socket88 As Socket
If Connected = True Then
VNC88
'Wait (15)
iommu
'KillVNC
Return True
Else
Socket88.Initialize("Socket88")
Socket88.Connect("192.168.1.111", 5988 , 3000 )
Return False
End If
End Sub