Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim mysocket As Socket
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
mysocket.Initialize("socket")
BindToLocalPort(mysocket, 54323)
mysocket.Connect("google.com", 80, 0)
End If
End Sub
Sub socket_Connected (Successful As Boolean)
Log(Successful)
End Sub
Sub BindToLocalPort(socket As Socket, port As Int)
Dim r As Reflector
r.Target = socket
Dim jo As JavaObject = r.GetField("socket")
Dim inet As JavaObject
Dim server As ServerSocket 'ignore
inet.InitializeNewInstance("java.net.InetSocketAddress", Array(server.GetMyIP, port))
jo.RunMethod("setReuseAddress", Array(True))
jo.RunMethod("bind", Array(inet))
End Sub