B4J Question [Solved] Client.RemotePort

Star-Dust

Expert
Licensed User
Longtime User
In the Network Client section there is RemoteAddress to know the ip address of the connected device, how can you also retrieve the port of the connected device?
 
It also works for B4A
B4X: Copy
Dim MySocket As Socket
' ......
Dim Sock As Reflector
Sock.Target=MySocket
Dim sor As JavaObject = Sock.GetField("socket")
remotePort=sor.RunMethod("getPort",Null)
remoteAddress=sor.RunMethod("getRemoteSocketAddress",Null)
' Address="/192.168.1.1:61061" ---
Address=Address.Replace("/","")
Address=Regex.Split(":",Address)(0)
 
Last edited:
Upvote 0
Back
Top