How to get remote IP address?

aroom

Member
Licensed User
search forum, get agraham idea:
You should be able to get the remote router IP address using the Door library to get the Server's Socket and then the Sockets' RemoteEndPoint and then the RemoteEndPoints' Address property.

agraham, give us the example. thanks.
 

agraham

Expert
Licensed User
Longtime User
It's something like this. I haven't tried it so it probably won't work so you'll have to see if you can get it going yourself.

B4X:
Obj1.New1(False)

server.Start
client.New1
client.Value = server.Accept 

Obj1.FromLibrary("client", "client", B4PObject(2)) ' get the .NET TcpClient
 ' this is the way to check you've got the object you want
Msgbox(Obj1.RunMethod("ToString"))

Obj1.Value = Obj1.GetProperty("Client") ' get the .NET Socket
Obj1.Value = Obj1.GetProperty("RemoteEndPoint") ' get the .NET RemoteEndPoint
Obj1.Value = Obj1.GetProperty("Address") ' get the remote .NET IPAddress
address = Obj1.RunMethod("ToString") ' get the dotted quad address
 
Top