OliverA Expert Licensed User Longtime User Oct 11, 2017 #1 How come this works: Code: Public Sub Initialize (server As FTPServer, socket As Socket, DataPort As Int) '... some code ... Dim r As Reflector r.Target = socket r.Target = r.GetField("socket") ' ... more code ... (The code above is taken from https://www.b4x.com/android/forum/threads/how-do-the-serversocket-look-up-the-ip-address-of-the-connected-client.28875/#post-167644) But Code: Public Sub Initialize (server As FTPServer, socket As Socket, DataPort As Int) '... some code ... Dim jo AsJavaObject = socket jo = jo.GetField("socket") '... more code... Throws java.lang.RuntimeException: Field: socket not found in: anywheresoftware.b4a.objects.SocketWrapper Click to expand... in B4A? BTW, the same JavaObject code works fine in B4J. Note: I'm modifying the FTP Server code (the FTPClient Initialize method). So if you need a running project, that is it (found here: https://www.b4x.com/android/forum/t...d-with-socket-and-asyncstreams.74320/#content)
How come this works: Code: Public Sub Initialize (server As FTPServer, socket As Socket, DataPort As Int) '... some code ... Dim r As Reflector r.Target = socket r.Target = r.GetField("socket") ' ... more code ... (The code above is taken from https://www.b4x.com/android/forum/threads/how-do-the-serversocket-look-up-the-ip-address-of-the-connected-client.28875/#post-167644) But Code: Public Sub Initialize (server As FTPServer, socket As Socket, DataPort As Int) '... some code ... Dim jo AsJavaObject = socket jo = jo.GetField("socket") '... more code... Throws java.lang.RuntimeException: Field: socket not found in: anywheresoftware.b4a.objects.SocketWrapper Click to expand... in B4A? BTW, the same JavaObject code works fine in B4J. Note: I'm modifying the FTP Server code (the FTPClient Initialize method). So if you need a running project, that is it (found here: https://www.b4x.com/android/forum/t...d-with-socket-and-asyncstreams.74320/#content)
Erel B4X founder Staff member Licensed User Longtime User Oct 12, 2017 #2 The socket field is private in B4A Socket library so you cannot access it with JavaObject. I will change it to be a public variable hidden with the @Hide annotation (as in B4J). Note that you can still use JavaObject, like this: Code: Dim jo As JavaObject = r.GetField("socket") Upvote 0
The socket field is private in B4A Socket library so you cannot access it with JavaObject. I will change it to be a public variable hidden with the @Hide annotation (as in B4J). Note that you can still use JavaObject, like this: Code: Dim jo As JavaObject = r.GetField("socket")