iOS Question getmyip problem

tufanv

Expert
Licensed User
Longtime User
Hello

I am trying to use
B4X:
    Dim server As ServerSocket 'ignore
   Log(server.GetMyIP)

to get the ip of the user but it returns the network local ip like 192.168.x.x , how can i get the real ip of the user ?

Ty
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
This is the real ip and the only ip address that is known to the device.

If you want the external ip address then you need to use a web service that will return it.

Example:
B4X:
Sub GetExternalIp As ResumableSub
   Dim j As HttpJob
   j.Initialize("", Me)
   j.Download("https://www.myexternalip.com/raw")
   Wait For (j) JobDone(j As HttpJob)
   Dim res As String = ""
   If j.Success Then
       res = j.GetString
   End If
   j.Release
   Return res
End Sub

Call it with:
B4X:
Wait For (GetExternalIp) Complete (Ip As String)
 
Upvote 0
Top