How to get public IP Address?

Hello all,

I am working on a pair of console apps where one is the client, the other the server. In the Connected Event of the Server I am using the following code to get the Public IP of the client that has connected

RemoteIP = Me.RemoteAddress

However, what I wind up getting is the Local IP of Server. What am I doing wrong?

Thanks
Tim

Does this thread help?
https://forum.xojo.com/44401-get-the-ip-internet-protocol

Thanks Tim,

I need the public IP of the client, once it has connected to the server. The server saves the Clients Public IP.
The thread you sent is interesting especially leading to the blog on IPify.

Tim

Tim,
I wound up sending the Client Public IP with the data from the client to the Server. Your link led me iify which works remarkable well!

Thanks Tim,
Tim

Just another one:

Function PublicIP() As string // Obtain public IP // Attention: do this within a separate thread since it takes a roundtrip to get ip Dim pubip As String Dim sck As New HTTPSocket Try Dim js As New JSONItem(sck.Get("http://ipinfo.io/json", 10)) If js.hasname("ip") Then pubip = js.value("ip") Catch RuntimeException pubip = "" End Try If sck <> Nil Then sck = Nil Return pubip End Function

1 Like

Thank you Joost.

Tim